public final class Tsid extends Object implements Serializable, Comparable<Tsid>
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
TSID_BYTES
Number of bytes of a TSID.
|
static int |
TSID_CHARS
Number of characters of a TSID.
|
static long |
TSID_EPOCH
Number of milliseconds of 2020-01-01T00:00:00.000Z.
|
| 构造器和说明 |
|---|
Tsid(long number)
Creates a new TSID.
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
compareTo(Tsid that)
Compares two TSIDs as unsigned 64-bit integers.
|
boolean |
equals(Object other)
Checks if some other TSID is equal to this one.
|
static Tsid |
from(byte[] bytes)
Converts a byte array into a TSID.
|
static Tsid |
from(long number)
Converts a number into a TSID.
|
static Tsid |
from(String string)
Converts a canonical string into a TSID.
|
java.time.Instant |
getInstant()
Returns the instant of creation.
|
java.time.Instant |
getInstant(java.time.Instant customEpoch)
Returns the instant of creation.
|
long |
getUnixMilliseconds()
Returns the time of creation in milliseconds since 1970-01-01.
|
long |
getUnixMilliseconds(long customEpoch)
Returns the time of creation in milliseconds since 1970-01-01.
|
int |
hashCode()
Returns a hash code value for the TSID.
|
static boolean |
isValid(String string)
Checks if the input string is valid.
|
byte[] |
toBytes()
Convert the TSID into a byte array.
|
long |
toLong()
Convert the TSID into a number.
|
String |
toLowerCase()
Converts the TSID into a canonical string in lower case.
|
String |
toString()
Converts the TSID into a canonical string in upper case.
|
public static final int TSID_BYTES
public static final int TSID_CHARS
public static final long TSID_EPOCH
public Tsid(long number)
This constructor wraps the input value in an immutable object.
number - a numberpublic static Tsid from(long number)
This method wraps the input value in an immutable object.
number - a numberpublic static Tsid from(byte[] bytes)
bytes - a byte arrayIllegalArgumentException - if bytes are null or its length is not 8public static Tsid from(String string)
The input string must be 13 characters long and must contain only characters from Crockford's base 32 alphabet.
The first character of the input string must be between 0 and F.
string - a canonical stringIllegalArgumentException - if the input string is invalidpublic static boolean isValid(String string)
The input string must be 13 characters long and must contain only characters from Crockford's base 32 alphabet.
The first character of the input string must be between 0 and F.
string - a stringpublic long toLong()
This method simply unwraps the internal value.
public byte[] toBytes()
public String toString()
The output string is 13 characters long and contains only characters from Crockford's base 32 alphabet.
For lower case string, use the shorthand Tsid#toLowerCase(), instead
of Tsid#toString()#toLowerCase().
toString 在类中 Objectpublic String toLowerCase()
The output string is 13 characters long and contains only characters from Crockford's base 32 alphabet.
It is faster shorthand for Tsid#toString()#toLowerCase().
public java.time.Instant getInstant()
The instant of creation is extracted from the time component.
Instantpublic java.time.Instant getInstant(java.time.Instant customEpoch)
The instant of creation is extracted from the time component.
customEpoch - the custom epoch instantInstantpublic long getUnixMilliseconds()
The time of creation is extracted from the time component.
public long getUnixMilliseconds(long customEpoch)
The time of creation is extracted from the time component.
customEpoch - the custom epoch in milliseconds since 1970-01-01public boolean equals(Object other)
public int compareTo(Tsid that)
The first of two TSIDs is greater than the second if the most significant byte in which they differ is greater for the first TSID.
compareTo 在接口中 Comparable<Tsid>that - a TSID to be compared withthis is less than, equal to, or greater than
thatCopyright © 2024. All rights reserved.