public final class SnowcastEpoch extends Object
The SnowcastEpoch is used to define a custom epoch for snowcast. A custom epoch is defined as a offset to the standard Java timestamp and is used to offer more bits to the internal timestamp value of a snowcast sequence ID.
To build a SnowcastEpoch multiple ways are possible. The most commonly used is utilizing the Java Calendar API as shown in the following snippet:
Calendar calendar = GregorianCalendar.getInstance(); calendar.set( 2014, 1, 1, 0, 0, 0 ); SnowcastEpoch epoch = SnowcastEpoch.byCalendar( calendar );
Another way is by providing a Java long timestamp value. The important note is, that Java timestamps are based on milliseconds whereas standard Linux timestamps are based on seconds
SnowcastEpoch epoch = SnowcastEpoch.byTimestamp( 13885308000000 );
Modifier and Type | Method and Description |
---|---|
static SnowcastEpoch |
byCalendar(Calendar calendar)
Creates a custom epoch based on the given
Calendar instance. |
static SnowcastEpoch |
byTimestamp(long timestamp)
Creates a custom epoch based on the given milliseconds based timestamp.
|
boolean |
equals(Object o) |
long |
getEpochOffset()
Returns the configured offset of this custom epoch.
|
long |
getEpochTimestamp()
Returns the current point in time as a timestamp based on this custom epoch.
|
int |
hashCode() |
String |
toString() |
public long getEpochTimestamp()
public long getEpochOffset()
public static SnowcastEpoch byCalendar(@Nonnull Calendar calendar)
Calendar
instance.calendar
- the calendar instance to base the epoch on@Nonnull public static SnowcastEpoch byTimestamp(@Nonnegative long timestamp)
timestamp
- the timestamp value to base the epoch onCopyright © 2014-2017. All Rights Reserved.