public final class UuidTime extends Object
The UUID time stamp is a 60-bit number.
The UUID time stamp resolution is 100ns, i.e., the UUID clock ticks every 100-nanosecond interval.
In JDK 8, Instant.now() has millisecond precision, in spite of
Instant has nanoseconds resolution. In JDK 9+,Instant.now()
has microsecond precision.
| Modifier and Type | Field and Description |
|---|---|
static Instant |
EPOCH_GREG
The Gregorian epoch.
|
static long |
EPOCH_GREG_SECONDS
The Gregorian epoch in seconds.
|
static Instant |
EPOCH_UNIX
The Unix epoch.
|
static long |
EPOCH_UNIX_SECONDS
The Unix epoch in seconds.
|
static long |
NANOS_PER_TICK
Number nanos per clock tick.
|
static long |
TICKS_PER_MILLI
Number of clock ticks per millisecond.
|
static long |
TICKS_PER_SECOND
Number of clock ticks per second.
|
| Modifier and Type | Method and Description |
|---|---|
static Instant |
fromGregTimestamp(long gregTimestamp)
Converts a number of 100ns since 1582-10-15 (Gregorian epoch) into an
Instant. |
static Instant |
fromUnixTimestamp(long unixTimestamp)
Converts a number of 100ns since 1970-01-01 (Unix epoch) into an
Instant. |
static long |
getGregTimestamp()
Returns the number of 100ns since 1582-10-15 (Gregorian epoch).
|
static long |
getUnixTimestamp()
Returns the number of 100ns since 1970-01-01 (Unix epoch).
|
static long |
toGregTimestamp(Instant instant)
Converts an
Instant into a number of 100ns since 1582-10-15
(Gregorian epoch). |
static long |
toGregTimestamp(long unixTimestamp)
Converts a number of 100ns since 1970-01-01 (Unix epoch) into a number of
100ns since 1582-10-15 (Gregorian epoch).
|
static long |
toUnixTimestamp(Instant instant)
Converts an
Instant into a number of 100ns since 1970-01-01 (Unix
epoch). |
static long |
toUnixTimestamp(long gregTimestamp)
Converts a number of 100ns since 1582-10-15 (Gregorian epoch) into a number
of 100ns since 1970-01-01 (Unix epoch).
|
public static final Instant EPOCH_UNIX
public static final Instant EPOCH_GREG
public static final long EPOCH_UNIX_SECONDS
public static final long EPOCH_GREG_SECONDS
public static final long NANOS_PER_TICK
public static final long TICKS_PER_MILLI
public static final long TICKS_PER_SECOND
public static long getUnixTimestamp()
It uses Instant.now() to get the the current time.
public static long getGregTimestamp()
It uses Instant.now() to get the the current time.
public static long toUnixTimestamp(long gregTimestamp)
gregTimestamp - a number of 100ns since 1582-10-15 (Gregorian epoch)public static long toGregTimestamp(long unixTimestamp)
unixTimestamp - a number of 100ns since 1970-01-01 (Unix epoch)public static long toUnixTimestamp(Instant instant)
Instant into a number of 100ns since 1970-01-01 (Unix
epoch).instant - an instantpublic static long toGregTimestamp(Instant instant)
Instant into a number of 100ns since 1582-10-15
(Gregorian epoch).instant - an instantpublic static Instant fromUnixTimestamp(long unixTimestamp)
Instant.unixTimestamp - a number of 100ns since 1970-01-01 (Unix epoch)Copyright © 2024. All rights reserved.