Package org.icij.datashare.time
Class DatashareTime
- java.lang.Object
-
- org.icij.datashare.time.DatashareTime
-
-
Field Summary
Fields Modifier and Type Field Description static StringDATASHARE_TIME_CLASS_PROPERTYproperty key for "org.icij.datashare.time.class"
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMilliseconds(int toBeAddedInMilliseconds)longcurrentTimeMillis()returns System.currentTimeMillis()static TimegetInstance()Singleton instance method.static DategetNow()static booleanisMockTime()DateitIsNow(String date)sets current date and returns this dateDatenow()returns system timevoidsetMockDate(String dateTime)sets current datevoidsetMockDate(Date date)sets current datestatic voidsetMockTime(boolean mockTime)voidsleep(int milliseconds)sleeps the given time
-
-
-
Field Detail
-
DATASHARE_TIME_CLASS_PROPERTY
public static final String DATASHARE_TIME_CLASS_PROPERTY
property key for "org.icij.datashare.time.class"- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static Time getInstance()
Singleton instance method. DATASHARE_TIME_CLASS_PROPERTY is defined in the JVM. this method returns an instance of the class provided in the property.- Returns:
Timedatashare time provider- See Also:
if class cannot be loaded by class loader or no default constructor is available, default time provider is returned.
-
now
public Date now()
returns system time
-
getNow
public static Date getNow()
-
currentTimeMillis
public long currentTimeMillis()
returns System.currentTimeMillis()- Specified by:
currentTimeMillisin interfaceTime- Returns:
- current milliseconds since 1st january 1970, 00:00:00 GMT
- See Also:
System.currentTimeMillis()
-
setMockDate
public void setMockDate(Date date)
Description copied from interface:Timesets current date- Specified by:
setMockDatein interfaceTime
-
sleep
public void sleep(int milliseconds) throws InterruptedExceptionDescription copied from interface:Timesleeps the given time- Specified by:
sleepin interfaceTime- Throws:
InterruptedException
-
setMockDate
public void setMockDate(String dateTime)
Description copied from interface:Timesets current date- Specified by:
setMockDatein interfaceTime- Parameters:
dateTime- formatted iso8601
-
addMilliseconds
public void addMilliseconds(int toBeAddedInMilliseconds)
- Specified by:
addMillisecondsin interfaceTime
-
setMockTime
public static void setMockTime(boolean mockTime)
-
isMockTime
public static boolean isMockTime()
-
-