Class UUIDv7

java.lang.Object
org.tailormap.api.util.UUIDv7

public class UUIDv7 extends Object
A utility class to create UUID version 7, which is time-sortable.
See Also:
  • Method Details

    • randomV7

      public static UUID randomV7()
      Create a random version 7 UUID.
      Returns:
      a random version 7 UUID
    • timestamp

      public static long timestamp(UUID uuidv7) throws IllegalArgumentException
      Extract the Unix epoch timestamp (milliseconds) from a UUIDv7.
      Parameters:
      uuidv7 - the UUIDv7 value
      Returns:
      the embedded Unix epoch timestamp in milliseconds
      Throws:
      IllegalArgumentException - if the given UUID is not version 7
    • timestampAsInstant

      public static Instant timestampAsInstant(UUID uuidv7) throws IllegalArgumentException
      Extract the Unix epoch timestamp as an Instant from a UUIDv7.
      Parameters:
      uuidv7 - the UUIDv7 value
      Returns:
      the embedded Unix epoch timestamp in milliseconds
      Throws:
      IllegalArgumentException - if the given UUID is not version 7
      See Also:
    • fromString

      public static UUID fromString(String value) throws IllegalArgumentException
      Parse a string representation of a UUIDv7.

      Accepts the standard xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.

      Parameters:
      value - the string to parse
      Returns:
      the parsed UUIDv7
      Throws:
      IllegalArgumentException - if the string is not a valid UUID or not version 7