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.
| 限定符和类型 | 字段和说明 |
|---|---|
static java.time.Instant |
EPOCH_GREG |
static long |
EPOCH_GREG_SECONDS |
static java.time.Instant |
EPOCH_UNIX |
static long |
EPOCH_UNIX_SECONDS |
static long |
NANOS_PER_TICK |
static long |
TICKS_PER_MILLI |
static long |
TICKS_PER_SECOND |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.time.Instant |
fromGregTimestamp(long gregTimestamp)
Converts a number of 100ns since 1582-10-15 (Gregorian epoch) into an
Instant. |
static java.time.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(java.time.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(java.time.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 java.time.Instant EPOCH_UNIX
public static final java.time.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(java.time.Instant instant)
Instant into a number of 100ns since 1970-01-01 (Unix
epoch).instant - an instantpublic static long toGregTimestamp(java.time.Instant instant)
Instant into a number of 100ns since 1582-10-15
(Gregorian epoch).instant - an instantpublic static java.time.Instant fromUnixTimestamp(long unixTimestamp)
Instant.unixTimestamp - a number of 100ns since 1970-01-01 (Unix epoch)public static java.time.Instant fromGregTimestamp(long gregTimestamp)
Instant.gregTimestamp - a number of 100ns since 1582-10-15 (Gregorian epoch)Copyright © 2024. All rights reserved.