framework
Class Time

java.lang.Object
  extended by framework.Time

public class Time
extends Object

Provides methods to get the time as accurately as is possible.

Prior to Java 5, the only clock available was System.currentTimeMillis(), which on Windows has an resolution of about 10-16ms. This class will use the newer System.nanoTime() if it is available, falling back to System.currentTimeMillis() if necessary.


Field Summary
static boolean nanoPrecision
          True if we have access to the System.nanoTime() clock.
 
Constructor Summary
Time()
           
 
Method Summary
static long getNanoTime()
          Get current time in nanoseconds.
static long getTime()
          Get current time in milliseconds.
static String toString(long time)
          Convert from an number of milliseconds to a String in "[HH:]MM:SS" format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nanoPrecision

public static final boolean nanoPrecision
True if we have access to the System.nanoTime() clock.

Constructor Detail

Time

public Time()
Method Detail

getTime

public static long getTime()
Get current time in milliseconds.

Returns:
current time in milliseconds

getNanoTime

public static long getNanoTime()
Get current time in nanoseconds.

Returns:
current time in nanoseconds

toString

public static String toString(long time)
Convert from an number of milliseconds to a String in "[HH:]MM:SS" format.

Parameters:
time - time in milliseconds
Returns:
a String containing a human-readable length of time