- java.lang.Object
-
- com.github.f4b6a3.ulid.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static UlidgetMonotonicUlid()Returns a Monotonic ULID.static UlidgetMonotonicUlid(long time)Returns a Monotonic ULID with a given time.static UlidgetUlid()Returns a ULID.static UlidgetUlid(long time)Returns a ULID with a given time.
-
-
-
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
-
-