Module com.github.f4b6a3.uuid
Interface TimeFunction
-
- All Superinterfaces:
LongSupplier
- All Known Implementing Classes:
DefaultTimeFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface TimeFunction extends LongSupplier
It must return a number of 100-nanoseconds since 1970-01-01 (Unix epoch). UsetoTimestamp(Instant)to convert the output to 100-nanoseconds since 1970-01-01 (Unix epoch). It also sets the output within the range 0 to 2^60-1. TheAbstTimeBasedFactorywill convert the output time to Gregorian epoch (1582-10-15) for you. Example:// A `TimeFunction` that returns the `Instant.now()` as a number of 100-nanoseconds TimeFunction f = () -> TimeFunction.toTimestamp(Instant.now()); // for JDK 9+
In JDK 8,Instant.now()has millisecond precision, in spite ofInstanthas nanoseconds resolution. In JDK 9+,Instant.now()has microsecond precision. Read: https://stackoverflow.com/questions/1712205 Read also: https://bugs.openjdk.java.net/browse/JDK-8068730
-
-
Method Summary
Static Methods Modifier and Type Method Description static longtoTimestamp(Instant instant)Converts an instant to a number of 100-nanoseconds since 1970-01-01 (Unix epoch).-
Methods inherited from interface java.util.function.LongSupplier
getAsLong
-
-
-
-
Method Detail
-
toTimestamp
static long toTimestamp(Instant instant)
Converts an instant to a number of 100-nanoseconds since 1970-01-01 (Unix epoch).- Parameters:
instant- an instant- Returns:
- a number of 100-nanoseconds since 1970-01-01 (Unix epoch)
-
-