public final class CivilTimeEncoder
extends java.lang.Object
The valid range and number of bits required by each date/time field is as the following:
Field | Range | #Bits |
---|---|---|
Year | [1, 9999] | 14 |
Month | [1, 12] | 4 |
Day | [1, 31] | 5 |
Hour | [0, 23] | 5 |
Minute | [0, 59] | 6 |
Second | [0, 59]* | 6 |
Micros | [0, 999999] | 20 |
Nanos | [0, 999999999] | 30 |
* Leap second is not supported.
When encoding the TIME or DATETIME into a bit field, larger date/time field is on the more significant side.
Modifier and Type | Method and Description |
---|---|
static LocalTime |
decodePacked32TimeSeconds(int bitFieldTimeSeconds)
Decodes
bitFieldTimeSeconds as a LocalTime with seconds precision. |
static java.time.LocalTime |
decodePacked32TimeSecondsAsJavaTime(int bitFieldTimeSeconds)
Decodes
bitFieldTimeSeconds as a LocalTime with seconds precision. |
static LocalDateTime |
decodePacked64DatetimeMicros(long bitFieldDatetimeMicros)
Decodes
bitFieldDatetimeMicros as a LocalDateTime with microseconds precision. |
static java.time.LocalDateTime |
decodePacked64DatetimeMicrosAsJavaTime(long bitFieldDatetimeMicros)
Decodes
bitFieldDatetimeMicros as a LocalDateTime with microseconds
precision. |
static LocalDateTime |
decodePacked64DatetimeSeconds(long bitFieldDatetimeSeconds)
Decodes
bitFieldDatetimeSeconds as a LocalDateTime with seconds precision. |
static java.time.LocalDateTime |
decodePacked64DatetimeSecondsAsJavaTime(long bitFieldDatetimeSeconds)
Decodes
bitFieldDatetimeSeconds as a LocalDateTime with seconds precision. |
static LocalTime |
decodePacked64TimeMicros(long bitFieldTimeMicros)
Decodes
bitFieldTimeMicros as a LocalTime with microseconds precision. |
static java.time.LocalTime |
decodePacked64TimeMicrosAsJavaTime(long bitFieldTimeMicros)
Decodes
bitFieldTimeMicros as a LocalTime with microseconds
precision. |
static LocalTime |
decodePacked64TimeNanos(long bitFieldTimeNanos)
Decodes
bitFieldTimeNanos as a LocalTime with nanoseconds precision. |
static java.time.LocalTime |
decodePacked64TimeNanosAsJavaTime(long bitFieldTimeNanos)
Decodes
bitFieldTimeNanos as a LocalTime with nanoseconds precision. |
static int |
encodePacked32TimeSeconds(LocalTime time)
Encodes
time as a 4-byte integer with seconds precision. |
static int |
encodePacked32TimeSeconds(java.time.LocalTime time)
Encodes
time as a 4-byte integer with seconds precision. |
static long |
encodePacked64DatetimeMicros(LocalDateTime dateTime)
Encodes
dateTime as a 8-byte integer with microseconds precision. |
static long |
encodePacked64DatetimeMicros(java.time.LocalDateTime dateTime)
Encodes
dateTime as a 8-byte integer with microseconds precision. |
static long |
encodePacked64DatetimeSeconds(LocalDateTime dateTime)
Encodes
dateTime as a 8-byte integer with seconds precision. |
static long |
encodePacked64DatetimeSeconds(java.time.LocalDateTime dateTime)
Encodes
dateTime as a 8-byte integer with seconds precision. |
static long |
encodePacked64TimeMicros(LocalTime time)
Encodes
time as a 8-byte integer with microseconds precision. |
static long |
encodePacked64TimeMicros(java.time.LocalTime time)
Encodes
time as a 8-byte integer with microseconds precision. |
static long |
encodePacked64TimeNanos(LocalTime time)
Encodes
time as a 8-byte integer with nanoseconds precision. |
static long |
encodePacked64TimeNanos(java.time.LocalTime time)
Encodes
time as a 8-byte integer with nanoseconds precision. |
public static int encodePacked32TimeSeconds(LocalTime time)
time
as a 4-byte integer with seconds precision.
Encoding is as the following:
3 2 1 MSB 10987654321098765432109876543210 LSB | H || M || S |
public static int encodePacked32TimeSeconds(java.time.LocalTime time)
time
as a 4-byte integer with seconds precision.
Encoding is as the following:
3 2 1 MSB 10987654321098765432109876543210 LSB | H || M || S |
decodePacked32TimeSecondsAsJavaTime(int)
public static LocalTime decodePacked32TimeSeconds(int bitFieldTimeSeconds)
bitFieldTimeSeconds
as a LocalTime
with seconds precision.
Encoding is as the following:
3 2 1 MSB 10987654321098765432109876543210 LSB | H || M || S |
encodePacked32TimeSeconds(LocalTime)
,
#encodePacked32TimeSecondsAsJavaTime(int)
public static java.time.LocalTime decodePacked32TimeSecondsAsJavaTime(int bitFieldTimeSeconds)
bitFieldTimeSeconds
as a LocalTime
with seconds precision.
Encoding is as the following:
3 2 1 MSB 10987654321098765432109876543210 LSB | H || M || S |
public static long encodePacked64TimeMicros(LocalTime time)
time
as a 8-byte integer with microseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||-------micros-----|
public static long encodePacked64TimeMicros(java.time.LocalTime time)
time
as a 8-byte integer with microseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||-------micros-----|
decodePacked64TimeMicrosAsJavaTime(long)
public static LocalTime decodePacked64TimeMicros(long bitFieldTimeMicros)
bitFieldTimeMicros
as a LocalTime
with microseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||-------micros-----|
Warning: LocalTime only supports milliseconds precision. Result is truncated.
public static java.time.LocalTime decodePacked64TimeMicrosAsJavaTime(long bitFieldTimeMicros)
bitFieldTimeMicros
as a LocalTime
with microseconds
precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||-------micros-----|
public static long encodePacked64TimeNanos(LocalTime time)
time
as a 8-byte integer with nanoseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||---------- nanos -----------|
public static long encodePacked64TimeNanos(java.time.LocalTime time)
time
as a 8-byte integer with nanoseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||---------- nanos -----------|
decodePacked64TimeNanosAsJavaTime(long)
public static LocalTime decodePacked64TimeNanos(long bitFieldTimeNanos)
bitFieldTimeNanos
as a LocalTime
with nanoseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||---------- nanos -----------|
Warning: LocalTime only supports milliseconds precision. Result is truncated.
public static java.time.LocalTime decodePacked64TimeNanosAsJavaTime(long bitFieldTimeNanos)
bitFieldTimeNanos
as a LocalTime
with nanoseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||---------- nanos -----------|
public static long encodePacked64DatetimeSeconds(LocalDateTime dateTime)
dateTime
as a 8-byte integer with seconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S |
public static long encodePacked64DatetimeSeconds(java.time.LocalDateTime dateTime)
dateTime
as a 8-byte integer with seconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S |
public static LocalDateTime decodePacked64DatetimeSeconds(long bitFieldDatetimeSeconds)
bitFieldDatetimeSeconds
as a LocalDateTime
with seconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S |
public static java.time.LocalDateTime decodePacked64DatetimeSecondsAsJavaTime(long bitFieldDatetimeSeconds)
bitFieldDatetimeSeconds
as a LocalDateTime
with seconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S |
public static long encodePacked64DatetimeMicros(LocalDateTime dateTime)
dateTime
as a 8-byte integer with microseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S ||-------micros-----|
public static long encodePacked64DatetimeMicros(java.time.LocalDateTime dateTime)
dateTime
as a 8-byte integer with microseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S ||-------micros-----|
public static LocalDateTime decodePacked64DatetimeMicros(long bitFieldDatetimeMicros)
bitFieldDatetimeMicros
as a LocalDateTime
with microseconds precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S ||-------micros-----|
Warning: LocalDateTime only supports milliseconds precision. Result is truncated.
public static java.time.LocalDateTime decodePacked64DatetimeMicrosAsJavaTime(long bitFieldDatetimeMicros)
bitFieldDatetimeMicros
as a LocalDateTime
with microseconds
precision.
Encoding is as the following:
6 5 4 3 2 1 MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB |--- year ---||m || D || H || M || S ||-------micros-----|