Date and Time Methods
The date and time methods are used to retrieve the current date and time as well as information on computation times.
'hr:min:sec', which returns the time in hours, minutes, and seconds in the form X hr Y min Z sec.
'h:min:s', which returns the time in hours, minutes, and seconds in the form X h Y min Z s.
'detailed', which returns the time in seconds and also includes more readable units for longer times.
You can use the timeStamp method to record time differences and set the measured time in ms (a long integer).
hr:min:sec Returns the time in hours, minutes, and seconds in the format X h Y min Z sec.
h:min:s Returns the time in hours, minutes, and seconds in the format X h Y min Z s.
detailed Returns the time in seconds and also includes more readable units for longer times. This format is localized and the output is translated to the current language setting.
Example Code
The following code overrides the built-in computation time that is available in the information nodes in the model tree.
long t0 = timeStamp(); // initialize record of computation time
 
// code and computations
 
model.setLastComputationTime(timeStamp()-t0); // record computation time
If it is possible to give a rough estimate of the computation time based on the given inputs of an application, you can update the expected computation time and display it in an information card stack or a text object. Assume that there is an integer input called objects that controls the number of objects in a geometry array and that the computation roughly increases linearly with this number. The following code adjusts the expected computation time accordingly.
// Number of minutes of computation time per object
int minutes = objects*2.1;
model.setExpectedComputationTime("About " + minutes + " minutes" );
Sleep
The code below makes the application idle for 1000 ms.
long delay = 1000;
sleep(delay);
This technique can be used to display graphics in a sequence.
For more information on information nodes and information cards, as well as the sleep method, see the book Introduction to the Application Builder.