|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gausssoft.util.Stopwatch
The Stopwatch class is a simple class emulating a Stopwatch by providing the same functionality.
When a Stopwatch is serialized, it remains in the same state as when it was an object. If you serialize a running Stopwatch, it will continue running and will show the correct time after deserialization.
All results returned are, by default, in milliseconds. The accuracy of the Stopwatch
is dependant upon the accuracy of System.currentTimeMillis()
, plus the amount of
overhead generated to perform each method.
This object is not thread safe.
System.currentTimeMillis()
, Serialized FormConstructor Summary | |
Stopwatch()
Constructs a new Stopwatch. |
|
Stopwatch(long time)
Constructs a new Stopwatch, specifying how much time has already elapsed. |
Method Summary | |
Object |
clone()
Creates a copy of this Stopwatch. |
boolean |
equals(Object obj)
Compares this object against another object. |
long |
get()
Gets the number of milliseconds elapsed so far. |
static long |
now()
Simple hook into System.currentTimeMillis() to provide the
current date in milliseconds. |
long |
offset(long off)
Adds a specified amount of milliseconds to the current amount of time elapsed. |
void |
reset()
Resets the time elapsed so far to 0. |
boolean |
running()
Indicates if the Stopwatch is running or not. |
void |
set(long set)
Sets the amount of milliseconds elapsed so far. |
void |
start()
Starts the Stopwatch. |
long |
stop()
Stops the Stopwatch running. |
String |
toString()
Returns a string representation of this Stopwatch. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Stopwatch()
public Stopwatch(long time)
time
- The number of milliseconds that have already passed.IllegalArgumentException
- If time
is less than 0.Method Detail |
public final void start()
public final long get()
public final long stop()
public final void reset()
public final void set(long set)
set
- The amount of milliseconds that have elapsed.IllegalArgumentException
- If set
is less than 0.public final long offset(long off)
The figure supplied can either be positive or negative. If the value specified pushes the amount of milliseconds elapsed to a negative figure, it will be set to 0.
off
- The number of milliseconds to add to the current value of
elapsed milliseconds.public static long now()
System.currentTimeMillis()
to provide the
current date in milliseconds.System.currentTimeMillis()
public final boolean running()
true
if the Stopwatch is currently running.public String toString()
The string returned will be of one of the following forms:
toString
in class Object
public boolean equals(Object obj)
This method returns true
only if the object provided
is another Stopwatch object, and it both Stopwatches show the same
amount of time that has elapsed.
equals
in class Object
obj
- The object to compare it to.true
if this object is as the one provided.public Object clone()
clone
in interface CloneableObject
clone
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |