Package me.ahoo.cosid

Class CosId

java.lang.Object
me.ahoo.cosid.CosId

public final class CosId extends Object
CosId constants and configuration values.

This class contains global constants used throughout the CosId library, including the epoch timestamp that serves as the base time for time-based ID generators like Snowflake.

The epoch is set to December 24, 2019, 16:00:00 UTC, which provides a good balance between maximizing the available time bits and keeping IDs relatively compact for the foreseeable future.

  • Field Details

    • COSID

      public static final String COSID
      The base name for CosId components and configuration properties.
      See Also:
    • COSID_PREFIX

      public static final String COSID_PREFIX
      The prefix used for CosId-related configuration properties.

      This is typically used when building configuration keys by appending specific component names or properties to this prefix.

      See Also:
    • COSID_EPOCH_DATE

      public static final LocalDateTime COSID_EPOCH_DATE
      UTC EPOCH DATE of CosId.

      This is the base timestamp used by time-based ID generators in the CosId library. It represents December 24, 2019, 16:00:00 UTC, which serves as the starting point for calculating time differences in ID generation.

      Using a custom epoch rather than the Unix epoch (January 1, 1970) allows time-based ID generators to use fewer bits for the timestamp portion, leaving more bits available for other components like machine ID or sequence.

    • COSID_EPOCH

      public static final long COSID_EPOCH
      COSID_EPOCH in milliseconds: 1577203200000.

      This is the millisecond representation of the CosId epoch timestamp. Time-based ID generators use this value as the offset when calculating the time portion of generated IDs.

      See Also:
    • COSID_EPOCH_SECOND

      public static final long COSID_EPOCH_SECOND
      COSID_EPOCH in seconds: 1577203200.

      This is the second representation of the CosId epoch timestamp. It's provided as a convenience for implementations that work with second-precision timestamps.

      See Also: