Parsing Engine

danbikel.util
Class Time

java.lang.Object
  extended by danbikel.util.Time

public class Time
extends Object

A simple class for keeping track of wall-clock time. This class also contains a utility method for converting a long representing milliseconds to a string representation of minutes, seconds and milliseconds.

See Also:
elapsedTime(long)

Constructor Summary
Time()
          Creates a Time object whose start time is System.currentTimeMillis.
Time(long startTime)
          Creates a Time object with the specified start time.
 
Method Summary
static long current()
          An alias for System.currentTimeMillis.
 long elapsedMillis()
          Returns the number of milliseconds since the start time of this object.
 long elapsedMinutes()
          Returns the (floor of the) number of minutes since the start time of this object.
static String elapsedTime(long elapsedMillis)
          Returns a string representing the length of the specified time of the form MM:SS.mmm where MM is the number of minutes, SS is the nubmer of seconds and mmm is the number of milliseconds.
 void reset()
          Resets the internal start time to be the current time.
 long startTime()
          Returns the start time of this object.
 String toString()
          Returns a string representation of the elapsed time since the start time of this Time object, using the output of elapsedTime(long).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Time

public Time()
Creates a Time object whose start time is System.currentTimeMillis.


Time

public Time(long startTime)
Creates a Time object with the specified start time.

Method Detail

reset

public void reset()
Resets the internal start time to be the current time.


toString

public String toString()
Returns a string representation of the elapsed time since the start time of this Time object, using the output of elapsedTime(long).

Overrides:
toString in class Object

startTime

public long startTime()
Returns the start time of this object.


elapsedMillis

public long elapsedMillis()
Returns the number of milliseconds since the start time of this object. This method is simply an alias for
current() - startTime()


elapsedMinutes

public long elapsedMinutes()
Returns the (floor of the) number of minutes since the start time of this object. This method is simply an alias for
elapsedMillis() / 60000
.


elapsedTime

public static final String elapsedTime(long elapsedMillis)
Returns a string representing the length of the specified time of the form
MM:SS.mmm
where MM is the number of minutes, SS is the nubmer of seconds and mmm is the number of milliseconds.


current

public static final long current()
An alias for System.currentTimeMillis.


Parsing Engine

Author: Dan Bikel.