public enum SystemTimeProvider extends Enum<SystemTimeProvider> implements TimeProvider
This provider keeps a running delta between
System.nanoTime() and System.currentTimeMillis().
The delta is adjusted whenever the calculated estimate falls behind
the millisecond tick or drifts more than one millisecond ahead. This
keeps the returned value monotonic and within roughly a millisecond of
the wall clock.
System.currentTimeMillis : |----|----|----|
System.nanoTime : --------->
^
| delta
currentTimeNanos() : --------->
Typical call latency is about 40 ns on modern hardware.| Enum Constant and Description |
|---|
INSTANCE |
| Modifier and Type | Field and Description |
|---|---|
static TimeProvider |
CLOCK |
| Modifier and Type | Method and Description |
|---|---|
long |
currentTimeMicros()
Returns the current wall-clock time in microseconds.
|
long |
currentTimeMillis()
Returns the current wall-clock time in milliseconds.
|
long |
currentTimeNanos()
Returns a nanosecond timestamp derived from
System.nanoTime() and
adjusted by delta. |
static SystemTimeProvider |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SystemTimeProvider[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SystemTimeProvider INSTANCE
public static TimeProvider CLOCK
public static SystemTimeProvider[] values()
for (SystemTimeProvider c : SystemTimeProvider.values()) System.out.println(c);
public static SystemTimeProvider valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic long currentTimeMillis()
currentTimeMillis in interface TimeProviderpublic long currentTimeMicros()
currentTimeMicros in interface TimeProviderpublic long currentTimeNanos()
System.nanoTime() and
adjusted by delta. The result is monotonic and kept within one
millisecond of System.currentTimeMillis().currentTimeNanos in interface TimeProviderCopyright © 2026 Chronicle Software Ltd. All rights reserved.