Class UlidCreator


  • public final class UlidCreator
    extends Object
    A class for generating ULIDs. The ULID has two components: - Time component: a part of 48 bits that represent the number of milliseconds since Unix Epoch, 1970-01-01. - Random component: a byte array of 80 bits that has a random value generated a secure random generator. The maximum ULIDs that can be generated per millisecond is 2^80.
    • Method Detail

      • getUlid

        public static Ulid getUlid()
        Returns a ULID. The random component is always reset to a new random value.
        Returns:
        a ULID
      • getUlid

        public static Ulid getUlid​(long time)
        Returns a ULID with a given time. The time must be the number of milliseconds since 1970-01-01 (Unix epoch).
        Parameters:
        time - a given time
        Returns:
        a ULID
      • getMonotonicUlid

        public static Ulid getMonotonicUlid()
        Returns a Monotonic ULID. The random component is reset to a new value whenever the time changes. If more than one ULID is generated within the same time, the random component is incremented by one.
        Returns:
        a ULID
      • getMonotonicUlid

        public static Ulid getMonotonicUlid​(long time)
        Returns a Monotonic ULID with a given time. The time must be the number of milliseconds since 1970-01-01 (Unix epoch). The random component is reset to a new value whenever the time changes. If more than one ULID is generated within the same time, the random component is incremented by one.
        Parameters:
        time - a given time
        Returns:
        a ULID