Package com.github.nanoflakes
Class Nanoflake
java.lang.Object
com.github.nanoflakes.Nanoflake
A Nanoflake.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongasLong()Gets the nanoflake value as a Long.asString()Gets the nanoflake value as a string.Gets the creation time as anOffsetDateTime.longGets the creation time.epoch()Gets this nanoflake's epoch as anOffsetDateTime.longGets this nanoflake's epoch.booleaninthashCode()toString()withRadix(int radix)Gets the nanoflake value as a string, using a specified radix.
-
Constructor Details
-
Nanoflake
public Nanoflake(long epoch, long value)Creates a new nanoflake.- Parameters:
epoch- the nanoflake's epoch.value- the nanoflake's value.
-
Nanoflake
Creates a new nanoflake, parsing the value from a string.- Parameters:
epoch- the nanoflake's epoch.value- the nanoflake's value.
-
Nanoflake
Creates a new nanoflake, parsing the value from a string with a radix.- Parameters:
epoch- the nanoflake's epoch.value- the nanoflake's value.radix- the radix of the nanoflake.
-
-
Method Details
-
asLong
public long asLong()Gets the nanoflake value as a Long.- Returns:
- the value as a long.
-
asString
Gets the nanoflake value as a string.- Returns:
- the value as a String.
-
withRadix
Gets the nanoflake value as a string, using a specified radix.- Parameters:
radix- the radix.- Returns:
- the value as a String.
-
creationTime
Gets the creation time as anOffsetDateTime.- Returns:
- a
OffsetDateTimeset to the creation time.
-
creationTimeMillis
public long creationTimeMillis()Gets the creation time.- Returns:
- the creation time in milliseconds.
-
epochMillis
public long epochMillis()Gets this nanoflake's epoch.- Returns:
- the epoch in milliseconds.
-
epoch
Gets this nanoflake's epoch as anOffsetDateTime.- Returns:
- a
OffsetDateTimeset to the epoch time.
-
equals
-
hashCode
public int hashCode() -
toString
-