public class ULID extends Object implements Comparable<ULID>, Serializable
01AN4Z07BY 79KA1307SR9X4MV3
|----------| |----------------|
Timestamp Randomness
48bits 80bits
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ULID o) |
boolean |
equals(Object obj) |
long |
getLeastSignificantBits()
获取最低有效位(Least Significant Bit),64 bit(8 bytes)
|
long |
getMostSignificantBits()
获取最高有效位(Most Significant Bit),64 bit(8 bytes)
|
byte[] |
getRandomness()
获取ULID的随机数部分
|
long |
getTimestamp()
获取ULID的时间戳部分
|
int |
hashCode() |
ULID |
increment()
自增ULID
|
ULID |
nextMonotonic(long timestamp)
获取下一个有序的ULID
|
static ULID |
of()
创建一个新的ULID,使用当前系统时间戳和随机数
|
static ULID |
of(byte[] data)
从bytes解析ULID
|
static ULID |
of(long timestamp)
创建一个新的ULID,使用指定系统时间戳和随机数
|
static ULID |
of(long timestamp,
byte[] randomness)
创建一个新的ULID,使用指定系统时间戳和指定填充数
|
static ULID |
of(long timestamp,
Random random)
创建一个新的ULID,使用指定系统时间戳和指定随机对象
|
static ULID |
of(String ulidString)
解析一个Crockford`s Base32的ULID
|
byte[] |
toBytes()
转为bytes值,16位,0-7为mostSignificantBits,8-15为leastSignificantBits
|
UUID |
toJdkUUID()
转为JDK的UUID
|
String |
toString() |
UUID |
toUUID()
转为UUID
|
public ULID(Number128 number128)
number128
- 16位数字public static ULID of()
public static ULID of(long timestamp)
timestamp
- 时间戳public static ULID of(long timestamp, Random random)
timestamp
- 时间戳random
- Random
public static ULID of(long timestamp, byte[] randomness)
timestamp
- 时间戳randomness
- 指定填充数public static ULID of(String ulidString)
ulidString
- Crockford`s Base32的ULIDpublic static ULID of(byte[] data)
data
- bytes,16位,0-7为mostSignificantBits,8-15为leastSignificantBitspublic long getMostSignificantBits()
public long getLeastSignificantBits()
public long getTimestamp()
public byte[] getRandomness()
public ULID increment()
public ULID nextMonotonic(long timestamp)
timestamp
- 时间戳public byte[] toBytes()
public UUID toUUID()
public UUID toJdkUUID()
public int compareTo(ULID o)
compareTo
in interface Comparable<ULID>
Copyright © 2025. All rights reserved.