Class CivilTimeEncoder (3.17.2)

publicfinalclass CivilTimeEncoder

Ported from ZetaSQL CivilTimeEncoder Original code can be found at: https://github.com/google/zetasql/blob/master/java/com/google/zetasql/CivilTimeEncoder.java Encoder for TIME and DATETIME values, according to civil_time encoding.

The valid range and number of bits required by each date/time field is as the following:

Range and bits for date/time fields
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.

Inheritance

java.lang.Object > CivilTimeEncoder

Static Methods

decodePacked64DatetimeMicros(long bitFieldDatetimeMicros)

publicstaticLocalDateTimedecodePacked64DatetimeMicros(longbitFieldDatetimeMicros)

This method is obsolete. Use #decodePacked64DatetimeMicrosLocalDateTime(long) instead.

Parameter
Name Description
bitFieldDatetimeMicros long
Returns
Type Description
org.threeten.bp.LocalDateTime

decodePacked64DatetimeMicrosLocalDateTime(long bitFieldDatetimeMicros)

publicstaticLocalDateTimedecodePacked64DatetimeMicrosLocalDateTime(longbitFieldDatetimeMicros)

Decodes bitFieldDatetimeMicros as a java.time.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-----|

See Also: #encodePacked64DatetimeMicros(LocalDateTime)

Parameter
Name Description
bitFieldDatetimeMicros long
Returns
Type Description
LocalDateTime

decodePacked64TimeMicros(long bitFieldTimeMicros)

publicstaticLocalTimedecodePacked64TimeMicros(longbitFieldTimeMicros)

This method is obsolete. Use #decodePacked64TimeMicrosLocalTime(long) instead.

Parameter
Name Description
bitFieldTimeMicros long
Returns
Type Description
org.threeten.bp.LocalTime

decodePacked64TimeMicrosLocalTime(long bitFieldTimeMicros)

publicstaticLocalTimedecodePacked64TimeMicrosLocalTime(longbitFieldTimeMicros)

Decodes bitFieldTimeMicros as a java.time.LocalTime with microseconds precision.

Encoding is as the following:

 6 5 4 3 2 1

MSB 3210987654321098765432109876543210987654321098765432109876543210 LSB | H || M || S ||-------micros-----|

See Also: #encodePacked64TimeMicros(LocalTime)

Parameter
Name Description
bitFieldTimeMicros long
Returns
Type Description
LocalTime

encodePacked64DatetimeMicros(LocalDateTime dateTime)

publicstaticlongencodePacked64DatetimeMicros(LocalDateTimedateTime)

This method is obsolete. Use #encodePacked64DatetimeMicrosLocalDateTime(java.time.LocalDateTime) instead.

Parameter
Name Description
dateTime org.threeten.bp.LocalDateTime
Returns
Type Description
long

encodePacked64DatetimeMicrosLocalDateTime(LocalDateTime dateTime)

publicstaticlongencodePacked64DatetimeMicrosLocalDateTime(LocalDateTimedateTime)

Encodes 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-----|

See Also: #decodePacked64DatetimeMicros(long)

Parameter
Name Description
dateTime LocalDateTime
Returns
Type Description
long

encodePacked64TimeMicros(LocalTime time)

publicstaticlongencodePacked64TimeMicros(LocalTimetime)

This method is obsolete. Use #encodePacked64TimeMicrosLocalTime(java.time.LocalTime) instead.

Parameter
Name Description
time org.threeten.bp.LocalTime
Returns
Type Description
long

encodePacked64TimeMicrosLocalTime(LocalTime time)

publicstaticlongencodePacked64TimeMicrosLocalTime(LocalTimetime)

Encodes 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-----|

See Also: #decodePacked64TimeMicros(long), #encodePacked64TimeMicros(LocalTime)

Parameter
Name Description
time LocalTime
Returns
Type Description
long

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月11日 UTC.