Package org.opennms.core.time
Class PseudoClock
- java.lang.Object
-
- org.opennms.core.time.PseudoClock
-
public class PseudoClock extends java.lang.Object
Singleton used to track and control time independently of the system clock. This class is currently shared by implementations and test APIs to help share the same reference point to time.- Author:
- jwhite
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
advanceTime(long duration, java.util.concurrent.TimeUnit unit)
Advances the clock timestatic PseudoClock
getInstance()
long
getTime()
Retrieves the current time.void
reset()
Resets the clock time to zero.
-
-
-
Method Detail
-
getInstance
public static PseudoClock getInstance()
-
reset
public void reset()
Resets the clock time to zero.
-
getTime
public long getTime()
Retrieves the current time.- Returns:
- current timestamp in ms
-
advanceTime
public long advanceTime(long duration, java.util.concurrent.TimeUnit unit)
Advances the clock time- Parameters:
duration
- duration of time in the given unitsunit
- time unit- Returns:
- the absolute timestamp of the clock, following the advance
-
-