Class Nanoflake

java.lang.Object
com.github.nanoflakes.Nanoflake

public class Nanoflake extends Object
  • 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

      public Nanoflake(long epoch, String value)
      Creates a new nanoflake, parsing the value from a string.
      Parameters:
      epoch - the nanoflake's epoch.
      value - the nanoflake's value.
    • Nanoflake

      public Nanoflake(long epoch, String value, int radix)
      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

      public String asString()
      Gets the nanoflake value as a string.
      Returns:
      the value as a String.
    • withRadix

      public String withRadix(int radix)
      Gets the nanoflake value as a string, using a specified radix.
      Parameters:
      radix - the radix.
      Returns:
      the value as a String.
    • creationTime

      public OffsetDateTime creationTime()
      Gets the creation time as an OffsetDateTime.
      Returns:
      a OffsetDateTime set 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

      public OffsetDateTime epoch()
      Gets this nanoflake's epoch as an OffsetDateTime.
      Returns:
      a OffsetDateTime set to the epoch time.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object