Package com.evolveum.midpoint.common
Class Clock
- java.lang.Object
-
- com.evolveum.midpoint.common.Clock
-
public class Clock extends Object
System-wide clock. This class provides current time. By default is only proxies the usual system current time functions. But it may be explicitly manipulated to artificially shift the time. This of little value for a running system but it is really useful in the tests. Especially tests that test time-based behavior. Using the Clock avoids changing the actual system time (or JVM's perception of time) therefore the tests are easier to use and usual tools still make sense (e.g. log record timestamps are correct).- Author:
- Radovan Semancik
-
-
Constructor Summary
Constructors Constructor Description Clock()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
currentTimeMillis()
XMLGregorianCalendar
currentTimeXMLGregorianCalendar()
static Clock
get()
void
init()
boolean
isFuture(long date)
boolean
isFuture(XMLGregorianCalendar date)
boolean
isPast(long date)
boolean
isPast(XMLGregorianCalendar date)
void
override(long overrideTimestamp)
void
override(XMLGregorianCalendar overrideTimestamp)
void
overrideDuration(Long offsetMillis)
Extends offset on top of existing offset.void
overrideDuration(String durationString)
Extends offset on top of existing offset.void
overrideDuration(Duration duration)
Extends offset on top of existing offset.void
overrideOffset(Long offsetMillis)
void
resetOverride()
-
-
-
Method Detail
-
init
@PostConstruct public void init()
-
get
public static Clock get()
-
currentTimeMillis
public long currentTimeMillis()
-
currentTimeXMLGregorianCalendar
public XMLGregorianCalendar currentTimeXMLGregorianCalendar()
-
isPast
public boolean isPast(long date)
-
isPast
public boolean isPast(XMLGregorianCalendar date)
-
isFuture
public boolean isFuture(long date)
-
isFuture
public boolean isFuture(XMLGregorianCalendar date)
-
override
public void override(long overrideTimestamp)
-
override
public void override(XMLGregorianCalendar overrideTimestamp)
-
overrideDuration
public void overrideDuration(String durationString)
Extends offset on top of existing offset.
-
overrideDuration
public void overrideDuration(Duration duration)
Extends offset on top of existing offset.
-
overrideDuration
public void overrideDuration(Long offsetMillis)
Extends offset on top of existing offset.
-
overrideOffset
public void overrideOffset(Long offsetMillis)
-
resetOverride
public void resetOverride()
-
-