public enum SystemTimeProvider extends Enum<SystemTimeProvider> implements TimeProvider
| Enum Constant and Description |
|---|
INSTANCE |
| Modifier and Type | Field and Description |
|---|---|
static TimeProvider |
CLOCK |
| Modifier and Type | Method and Description |
|---|---|
long |
currentTimeMicros()
Retrieves the current time in microseconds.
|
long |
currentTimeMillis()
Retrieves the current time in milliseconds.
|
long |
currentTimeNanos()
Retrieves the current time in nanoseconds.
|
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()
TimeProviderThis method returns the current time with millisecond precision, measured from the Unix epoch (00:00:00 UTC on 1 January 1970). It is expected to be implemented by all subclasses, providing the baseline precision for time measurements.
currentTimeMillis in interface TimeProviderpublic long currentTimeMicros()
TimeProvider
This default implementation offers microsecond precision by scaling the millisecond value from
TimeProvider.currentTimeMillis() by a factor of 1000. Implementations may override this for higher
accuracy if available.
currentTimeMicros in interface TimeProviderpublic long currentTimeNanos()
TimeProvider
This default method provides nanosecond precision by further scaling the microsecond value
from TimeProvider.currentTimeMicros() by 1000. Implementations may provide more precise or direct
measurements if their underlying system supports it.
currentTimeNanos in interface TimeProviderCopyright © 2024. All rights reserved.