Package net.targetr.wtm3.util
Class Clock
java.lang.Object
net.targetr.wtm3.util.Clock
Abstraction for the system clock.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longmillis()Returns the current time in milliseconds since unix epoch.static longrealtime()Returns the current time in milliseconds since some arbitrary time in the past.static voidsleep(int millis) Pauses the current thread for the specified number of milliseconds.
-
Constructor Details
-
Clock
public Clock()Default constructor for Clock.
-
-
Method Details
-
millis
public static long millis()Returns the current time in milliseconds since unix epoch.- Returns:
- Time in milliseconds since unix epoch.
-
realtime
public static long realtime()Returns the current time in milliseconds since some arbitrary time in the past. This method is useful for measuring elapsed time.- Returns:
- A value in milliseconds for measuring time differences..
-
sleep
public static void sleep(int millis) Pauses the current thread for the specified number of milliseconds.- Parameters:
millis- The number of milliseconds to sleep.- Throws:
RuntimeException- If the thread is interrupted while sleeping.
-