public class Uuids extends Object
Adapted from the Java driver class of the same name (also under Apache v2 license).
| Modifier and Type | Method and Description |
|---|---|
static UUID |
timeBased()
Creates a new time-based (version 1) UUID.
|
static long |
unixTimestamp(UUID uuid)
Returns the Unix timestamp contained by the provided time-based UUID.
|
public static UUID timeBased()
UUIDs generated by this method are suitable for use with the timeuuid Cassandra
type. In particular the generated UUID includes the timestamp of its generation.
public static long unixTimestamp(@NonNull
UUID uuid)
This method is not equivalent to UUID.timestamp(). More precisely, a version 1 UUID
stores a timestamp that represents the number of 100-nanoseconds intervals since midnight, 15
October 1582 and that is what UUID.timestamp() returns. This method however converts
that timestamp to the equivalent Unix timestamp in milliseconds, i.e. a timestamp representing
a number of milliseconds since midnight, January 1, 1970 UTC. In particular, the timestamps
returned by this method are comparable to the timestamps returned by System.currentTimeMillis(), Date.getTime(), etc.
IllegalArgumentException - if uuid is not a version 1 UUID.Copyright © 2023. All rights reserved.