public class UUIDGen
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
decompose(java.util.UUID uuid)
decomposes a uuid into raw bytes.
|
static long |
getAdjustedTimestamp(java.util.UUID uuid)
Returns a milliseconds-since-epoch value for a type-1 UUID.
|
static java.util.UUID |
getTimeUUID()
Creates a type 1 UUID (time-based UUID).
|
static byte[] |
getTimeUUIDBytes()
Returns a 16 byte representation of a type 1 UUID (a time-based UUID),
based on the current system time.
|
static byte[] |
getTimeUUIDBytes(long timeMillis)
Converts a milliseconds-since-epoch timestamp into the 16 byte representation
of a type 1 UUID (a time-based UUID).
|
static byte[] |
getTimeUUIDBytes(long timeMillis,
int nanos)
Converts a 100-nanoseconds precision timestamp into the 16 byte representation
of a type 1 UUID (a time-based UUID).
|
static java.util.UUID |
getUUID(java.nio.ByteBuffer raw)
creates a type 1 uuid from raw bytes.
|
static java.util.UUID |
maxTimeUUID(long timestamp)
Returns the biggest possible type 1 UUID having the provided timestamp.
|
static java.util.UUID |
minTimeUUID(long timestamp)
Returns the smaller possible type 1 UUID having the provided timestamp.
|
static long |
unixTimestamp(java.util.UUID uuid) |
public static java.util.UUID getTimeUUID()
public static java.util.UUID getUUID(java.nio.ByteBuffer raw)
public static byte[] decompose(java.util.UUID uuid)
public static byte[] getTimeUUIDBytes()
public static java.util.UUID minTimeUUID(long timestamp)
public static java.util.UUID maxTimeUUID(long timestamp)
public static long unixTimestamp(java.util.UUID uuid)
public static byte[] getTimeUUIDBytes(long timeMillis)
Deprecated: This method goes again the principle of a time UUID and should not be used. For queries based on timestamp, minTimeUUID() and maxTimeUUID() can be used but this method has questionable usefulness. This is only kept because CQL2 uses it (see TimeUUID.fromStringCQL2) and we don't want to break compatibility.
Warning: This method is not guaranteed to return unique UUIDs; Multiple invocations using identical timestamps will result in identical UUIDs.
timeMillis
- public static byte[] getTimeUUIDBytes(long timeMillis, int nanos)
Warning: This method is not guaranteed to return unique UUIDs; Multiple invocations using identical timestamps will result in identical UUIDs.
public static long getAdjustedTimestamp(java.util.UUID uuid)
uuid
- a type-1 (time-based) UUIDjava.lang.IllegalArgumentException
- if the UUID is not version 1Copyright © 2013 The Apache Software Foundation