public abstract class AbstractChrono
extends java.lang.Object
Every object of class AbstractChrono acts as an independent stopwatch.
Several AbstractChrono objects can run at any given time.
The method init resets the stopwatch to zero,
getSeconds, getMinutes and getHours
return its current reading,
and format converts this reading to a String.
The returned value includes the execution time of the method
from AbstractChrono.
Below is an example of how it may be used. A stopwatch named timer is constructed (and initialized). When 2.1 seconds of CPU time have been consumed, the stopwatch is read and reset to zero. Then, after an additional 330 seconds (or 5.5 minutes) of CPU time, the stopwatch is read again and the value is printed to the output in minutes.
| Constructor and Description |
|---|
AbstractChrono() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
format()
Converts the CPU time used by the program since its last
call to
init for this AbstractChrono to a
String in the HH:MM:SS.xx format. |
static java.lang.String |
format(double time)
Converts the time time, given in seconds, to a
String in the HH:MM:SS.xx format. |
double |
getHours()
Returns the CPU time in hours used by the program since the last call to
init for this AbstractChrono. |
double |
getMinutes()
Returns the CPU time in minutes used by the program since the last call to
init for this AbstractChrono. |
double |
getSeconds()
Returns the CPU time in seconds used by the program since the last call to
init for this AbstractChrono. |
void |
init()
Initializes this AbstractChrono to zero.
|
public void init()
public double getSeconds()
init for this AbstractChrono.public double getMinutes()
init for this AbstractChrono.public double getHours()
init for this AbstractChrono.public java.lang.String format()
init for this AbstractChrono to a
String in the HH:MM:SS.xx format.public static java.lang.String format(double time)
String in the HH:MM:SS.xx format.To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.