Class UUIDUtils


  • public class UUIDUtils
    extends java.lang.Object
    Class used to generate UUID values.
    • Constructor Summary

      Constructors 
      Constructor Description
      UUIDUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.UUID generateNewUUID()
      Generate new UUID.
      static java.util.UUID generateNewUUID​(java.time.Instant instant)
      Generate new UUID for an instant of time.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UUIDUtils

        public UUIDUtils()
    • Method Detail

      • generateNewUUID

        public static java.util.UUID generateNewUUID()
        Generate new UUID. Each function call returns a new UUID value.

        UUID version is an implementation detail, and should not be relied on. For now it is UUIDv7, so for increasing instant values, returned UUID is always greater than previous one.

        Returns:
        UUID v7
        Since:
        1.15.0
      • generateNewUUID

        public static java.util.UUID generateNewUUID​(java.time.Instant instant)
        Generate new UUID for an instant of time. Each function call returns a new UUID value.

        UUID version is an implementation detail, and should not be relied on. For now it is UUIDv7, so for increasing instant values, returned UUID is always greater than previous one.

        Based on com.github.f4b6a3.uuid.UuidCreator.getTimeOrderedEpoch implementation (MIT License).

        Parameters:
        instant - a given instant
        Returns:
        UUID v7
        Since:
        1.15.0