Class CosId
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe base name for CosId components and configuration properties.static final longCOSID_EPOCH in milliseconds: 1577203200000.static final LocalDateTimeUTC EPOCH DATE of CosId.static final longCOSID_EPOCH in seconds: 1577203200.static final StringThe prefix used for CosId-related configuration properties. -
Method Summary
-
Field Details
-
COSID
The base name for CosId components and configuration properties.- See Also:
-
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
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_EPOCHCOSID_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_SECONDCOSID_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:
-