UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.util
Class Timer

java.lang.Object
  |
  +--edu.berkeley.guir.lib.util.Timer

public class Timer
extends Object

A class for doing stopwatch times.

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Oct 16 1997, JH
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
1.1.4
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu)

Constructor Summary
Timer()
          Default constructor.
 
Method Summary
 long getElapsedTime()
          Get the elapsed time so far.
 long getStartTime()
          Get the start time of the timer.
 long getStopTime()
          Get the stop time of the timer.
 boolean isRunning()
          See if the Timer is running or not.
 void resetTimer()
          Completely reset the timer so that it is a new timer.
 void start()
          Start the timer.
 void stop()
          Stop the timer only if it is already running.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timer

public Timer()
Default constructor.
Method Detail

getElapsedTime

public long getElapsedTime()
Get the elapsed time so far. If the timer is running, it does not stop it. If the timer is not running, then it gets the total elapsed time so far.
Returns:
A long representing the elapsed time so far.

getStartTime

public long getStartTime()
Get the start time of the timer.
Returns:
Returns the system time (milliseconds) when the Timer was started. Returns -1 if the Timer has not been started.

getStopTime

public long getStopTime()
Get the stop time of the timer.
Returns:
Returns the system time (milliseconds) when the Timer was stopped. Returns -1 if the Timer has not been stopped.

isRunning

public boolean isRunning()
See if the Timer is running or not.
Returns:
true if the Timer is running, false otherwise.

start

public void start()
Start the timer.

stop

public void stop()
Stop the timer only if it is already running.

resetTimer

public void resetTimer()
Completely reset the timer so that it is a new timer.

toString

public String toString()
Overrides:
toString in class Object

Copyright Information