OpMath

com.opmath.util.time
Class Timer

java.lang.Object
  |
  +--com.opmath.util.time.Timer

public class Timer
extends Object

A general purpose millisecond timer.

The timer is structured so as to support output in hours, minutes, seconds, and milliseconds.

NOTE: All Timer methods are synchronized.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3.0
Version:
utilities-v011
Author:
Bruno Beloff bruno.beloff@opmath.com

Constructor Summary
Timer()
          Constructs a new Timer object.
 
Method Summary
 long getHours()
          Returns the elapsed time in hours.
 long getMinutes()
          Returns the elapsed time in minutes.
 long getSeconds()
          Returns the elapsed time in seconds.
 long getTime()
          Returns the elapsed time in milliseconds.
 void mark()
          Reset the elapsed time counter.
 String toString()
          Returns the elapsed time as a formatted String.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timer

public Timer()

Constructs a new Timer object.

The timer is initially set to 0. Thus, if the elapsed time for this Timer object is read before mark() is called, the time will equal the System time.

Since:
J2SE 1.3
See Also:
mark()
Method Detail

mark

public void mark()

Reset the elapsed time counter.

If the elapsed time is subsequently read, it will equal the difference between the time at which mark() is executed, and the current System time.

Since:
J2SE 1.3

getTime

public long getTime()

Returns the elapsed time in milliseconds.

Returns:
A long number of milliseconds.
Since:
J2SE 1.3

getHours

public long getHours()

Returns the elapsed time in hours.

Returns:
A long number of whole hours.
Since:
J2SE 1.3

getMinutes

public long getMinutes()

Returns the elapsed time in minutes.

Returns:
A long number of whole minutes.
Since:
J2SE 1.3

getSeconds

public long getSeconds()

Returns the elapsed time in seconds.

Returns:
A long number of whole seconds.
Since:
J2SE 1.3

toString

public String toString()

Returns the elapsed time as a formatted String. The returned string is in the form: hhh:mm:ss.ttt.

Overrides:
toString in class Object
Returns:
A Type carrying something.
Since:
J2SE 1.3

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK