Package io.deephaven.base.clock
Interface SystemClock
- All Superinterfaces:
Clock
- All Known Implementing Classes:
SystemClockMillis,SystemClockUtc
A marker interface for
Clock that designates implementations as system clocks.-
Field Summary
Fields -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic SystemClockof()Creates a new system clock, or returns the singleton instance, based on system property "deephaven.systemClock" (uses "default" if not present).static Optional<SystemClock>UsesServiceLoader.load(Class)withSystemClock.classto load a system clock.static SystemClockThe system clock, based off ofSystem.currentTimeMillis().static SystemClockThe system clock, based off ofClock.systemUTC().Methods inherited from interface io.deephaven.base.clock.Clock
currentTimeMicros, currentTimeMillis, currentTimeNanos, instantMillis, instantNanos
-
Field Details
-
KEY
- See Also:
-
DEFAULT
- See Also:
-
SERVICE_LOADER
- See Also:
-
SYSTEM_UTC
- See Also:
-
SYSTEM_MILLIS
- See Also:
-
-
Method Details
-
of
static SystemClock of() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessExceptionCreates a new system clock, or returns the singleton instance, based on system property "deephaven.systemClock" (uses "default" if not present).Property Value Logic "default" serviceLoader().orElse(systemUTC())"serviceLoader" serviceLoader().orElseThrow()"systemUTC" systemUTC()"systemMillis" systemMillis()value (SystemClock) Class.forName(value).getDeclaredConstructor().newInstance()- Returns:
- a new instance of the system clock
- Throws:
ClassNotFoundExceptionNoSuchMethodExceptionInvocationTargetExceptionInstantiationExceptionIllegalAccessException- See Also:
-
systemUTC
The system clock, based off ofClock.systemUTC().- Returns:
- the system clock
- See Also:
-
systemMillis
The system clock, based off ofSystem.currentTimeMillis().- Returns:
- the millis-based system clock
- See Also:
-
serviceLoader
UsesServiceLoader.load(Class)withSystemClock.classto load a system clock.If a
ServiceConfigurationErroris thrown, the error will be logged toSystem.errandOptional.empty()will be returned.- Returns:
- the service loader system clock
- Throws:
IllegalStateException- if more than one system clock is registered
-