Package org.frankframework.util
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 Clock
getClock()
Get theClock
currently being used.static Instant
now()
Get the current system time asInstant
.static Date
Get the current system time as a legacyDate
.static void
ONLY FOR UNIT TESTING!static void
ONLY FOR UNIT TESTING!static void
setTime
(LocalDateTime localDateTime) ONLY FOR UNIT TESTING!static void
setTime
(ZonedDateTime zonedDateTime) ONLY FOR UNIT TESTING!
-
Method Details
-
now
Get the current system time asInstant
. -
nowAsDate
Get the current system time as a legacyDate
. -
setClock
ONLY FOR UNIT TESTING! Set a clock to use. Typically this is for testing, when you want to use a more specializedClock
to set a specific time or behaviour than can be done by setting a clock with a fixed point in time.- Parameters:
clock
-Clock
to use.
-
getClock
Get theClock
currently being used. This clock can be used to get the current time, or as a base-clock to create other specialized clocks for testing, which is the reason to make it accessible. -
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.
-