public class UlidUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
UlidUtil.UlidUtilException |
| Modifier and Type | Field and Description |
|---|---|
protected static long |
TIMESTAMP_MAX |
protected static String |
ULID_PATTERN_LOOSE |
protected static String |
ULID_PATTERN_STRICT |
| Modifier and Type | Method and Description |
|---|---|
static Instant |
extractInstant(String ulid) |
static String |
extractRandomnessComponent(String ulid) |
static long |
extractTimestamp(String ulid) |
static String |
extractTimestampComponent(String ulid) |
protected static long |
extractUnixMilliseconds(String ulid) |
static String |
fromBytesToUlid(byte[] bytes)
Convert an array of bytes to a ULID string.
|
static UUID |
fromBytesToUuid(byte[] bytes)
Get a UUID from an array of bytes;
|
static byte[] |
fromUlidToBytes(String ulid)
Convert a ULID string to an array of bytes.
|
static UUID |
fromUlidToUuid(String ulid)
Converts a ULID string to a UUID.
|
static byte[] |
fromUuidToBytes(UUID uuid)
Get the array of bytes from a UUID.
|
static String |
fromUuidToUlid(UUID uuid)
Convert a UUID to ULID string
|
static boolean |
isValid(String ulid)
Checks if the string is a valid ULID.
|
static boolean |
isValid(String ulid,
boolean strict)
Checks if the string is a valid ULID.
|
protected static void |
validate(String ulid)
Checks if the ULID string is a valid.
|
protected static void |
validate(String ulid,
boolean strict)
Checks if the ULID string is a valid.
|
protected static final long TIMESTAMP_MAX
protected static final String ULID_PATTERN_STRICT
protected static final String ULID_PATTERN_LOOSE
public static String fromUuidToUlid(UUID uuid)
uuid - a UUIDpublic static UUID fromUlidToUuid(String ulid)
ulid - a ULIDpublic static byte[] fromUuidToBytes(UUID uuid)
uuid - a UUIDpublic static UUID fromBytesToUuid(byte[] bytes)
bytes - an array of bytespublic static String fromBytesToUlid(byte[] bytes)
bytes - a byte arraypublic static byte[] fromUlidToBytes(String ulid)
ulid - a ULID stringprotected static void validate(String ulid)
validate(String, boolean).ulid - a ULIDprotected static void validate(String ulid, boolean strict)
validate(String, boolean).ulid - a ULIDpublic static boolean isValid(String ulid)
validate(String, boolean).public static boolean isValid(String ulid, boolean strict)
Strict validation: checks if the string is in the ULID specification format: - 0123456789ABCDEFGHJKMNPKRS (26 alphanumeric, case insensitive, except iI, lL, oO and uU) Loose validation: checks if the string is in one of these formats: - 0123456789ABCDEFGHIJKLMNOP (26 alphanumeric, case insensitive, except uU)
ulid - a ULIDstrict - true for strict validation, false for loose validationpublic static long extractTimestamp(String ulid)
protected static long extractUnixMilliseconds(String ulid)
Copyright © 2020. All rights reserved.