@FunctionalInterface public interface TimeFunction extends java.util.function.LongSupplier
Example:
// A function that returns `Instant.now()` as a number of 100ns
TimeFunction f = () -> TimeFunction.toUnixTimestamp(Instant.now());
In JDK 8, Instant.now() has millisecond precision, in spite of
Instant has nanoseconds resolution. In JDK 9+, Instant.now()
has microsecond precision.
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
toExpectedRange(long timestamp)
Clears the leading bits so that the resulting number is in the range 0 to
2^60-1.
|
static long |
toUnixTimestamp(java.time.Instant instant)
Converts an instant to a number of 100-nanoseconds since 1970-01-01 (Unix
epoch).
|
getAsLongstatic long toUnixTimestamp(java.time.Instant instant)
instant - an instantstatic long toExpectedRange(long timestamp)
The result is equivalent to n % 2^60.
timestamp - a number of 100-nanoseconds since 1970-01-01 (Unix epoch)Copyright © 2024. All rights reserved.