net.sf.rej.util
Class StopWatch

java.lang.Object
  extended by net.sf.rej.util.StopWatch

public class StopWatch
extends java.lang.Object

Utility class for measuring the duration of tasks for informal uses. Has an elapsedSeconds method for retrieving the time elapsed between calls to the methods start and stop in seconds.

Author:
Sami Koivu

Constructor Summary
StopWatch()
          Initializes a new object and starts the timer.
StopWatch(boolean start)
          Initializes a new object and depending on the given parameter either stars the timer, or not.
 
Method Summary
 int elapsedSeconds()
          Returns the number of elapsed seconds since the timer was started (either via the constructor or a call to the start method).
 void start()
          Starts the timer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StopWatch

public StopWatch()
Initializes a new object and starts the timer.


StopWatch

public StopWatch(boolean start)
Initializes a new object and depending on the given parameter either stars the timer, or not. If the timer is not started it may be started with a call to the start method.

Parameters:
start -
Method Detail

start

public void start()
Starts the timer. This method may only be called once per object.


elapsedSeconds

public int elapsedSeconds()
Returns the number of elapsed seconds since the timer was started (either via the constructor or a call to the start method).

Returns:
seconds elapsed.