Class Timer
java.lang.Object
solvers.utilities.Timer
The Timer object can receive "start" and "pause" commands. It can also
return the time interval in various formats.
- Author:
- Michail Makaronidis, 2009, 2010
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongThis method returns the sum of time intervals in msecs between every start and pause of the timer.This method returns the sum of time intervals between every start and pause of the timer in a pretty form.voidpause()Stops the timer, i.e.voidstart()Starts the timer, i.e.
-
Constructor Details
-
Timer
public Timer()Creates and initialises a Timer object. -
Timer
public Timer(long interval) Creates and initialises a Timer object. The initial time interval is set equal to the argument interval.- Parameters:
interval- The desired interval in msecs
-
-
Method Details
-
start
public void start()Starts the timer, i.e. sets the current time as the beginning of the interval. -
pause
public void pause()Stops the timer, i.e. sets the current time as the end of the interval. -
getInterval
public long getInterval()This method returns the sum of time intervals in msecs between every start and pause of the timer. The result is valid only if each start call is followed by a subsequent pause call.- Returns:
- Time interval in msecs
-
getPrettyInterval
This method returns the sum of time intervals between every start and pause of the timer in a pretty form. The result is valid only if each start call is followed by a subsequent pause call.- Returns:
- String representing the time interval in pretty form.
-