Class TimeProvider
java.lang.Object
org.frankframework.util.TimeProvider
This class provides a way to get current time, but also control time in unit tests.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClockgetClock()Get theClockcurrently being used.static Instantnow()Get the current system time asInstant.static DateGet the current system time as a legacyDate.static LocalDateTimeGet the current system time asLocalDateTimestatic longGet the current system time as clock millis (equivalent toSystem.currentTimeMillis()).static ZonedDateTimeGet the current system time asZonedDateTimestatic voidONLY FOR UNIT TESTING!static voidONLY FOR UNIT TESTING!static voidsetTime(long millis) ONLY FOR UNIT TESTING!static voidsetTime(LocalDateTime localDateTime) ONLY FOR UNIT TESTING!static voidsetTime(ZonedDateTime zonedDateTime) ONLY FOR UNIT TESTING!
-
Method Details
-
now
-
nowAsMillis
public static long nowAsMillis()Get the current system time as clock millis (equivalent toSystem.currentTimeMillis()). -
nowAsZonedDateTime
Get the current system time asZonedDateTime -
nowAsLocalDateTime
Get the current system time asLocalDateTime -
nowAsDate
-
setClock
-
getClock
-
setTime
public static void setTime(long millis) ONLY FOR UNIT TESTING! Set the clock to a fixed date-time from the milliseconds since 1-1-1970 passed in.- Parameters:
millis- Time in epoch-milliseconds to which to set the clock.
-
setTime
ONLY FOR UNIT TESTING! Set the clock to a fixed date-time from the local date-time passed in.- Parameters:
localDateTime- Time to which to set the clock.
-
setTime
ONLY FOR UNIT TESTING! Set the clock to a fixed date-time from the date-time invalid input: '&' timezone passed in.- Parameters:
zonedDateTime- The time to which to set the clock.
-
resetClock
public static void resetClock()ONLY FOR UNIT TESTING! Resets the clock to the default System UTC clock. This should be used in the test-teardown method of unit tests when the unit tests have set the clock to a none-default clock.
-