/*
File: Timer.java
CVS Info:
Compiler: jdk 1.3
*/
package mil.navy.nps.dis;
import java.lang.System.*;
/**
* This Java class provides a simple timer using the system clock converted to seconds.
*
*@version 1.0
*@author Scott Heller
*(http://web.nps.navy.mil/~brutzman)
* This code includes parts of Kent Watsen's EAI-based World.java/Ownship.java
* and Don McGregors's testing/BehaviorStreamBufferTest.java
*
*
Location:
*
* http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/Timer.java
*
*History:
*
*
* 13 December 1998
* | Scott Heller
* | New
* |
*/
public class Timer
{
private long startTime = 0;
/**
* Constuctor: Sets the current timer to zero.
*/
public Timer()
{
startTime = System.currentTimeMillis();
}
/**
* Sets the current timer to zero.
*/
public void reset()
{
startTime = System.currentTimeMillis();
}
/**
* Returns the number of seconds since the timer was reset.
*/
public float getDuration()
{
return toSec( System.currentTimeMillis() - startTime );
}
public String toString()
{
return ("" + getDuration() );
}
private float toSec( long t )
{
return (float)t / 1000;
}
}// end class timer