public class LocalTimeCodec extends Object
Encodes and decodes LocalTime
objects to and from DateTime
. Data is stored to millisecond accuracy.
Converts the LocalTime
values to and from EpochDay at ZoneOffset.UTC
.
Note: Requires Java 8 or greater.
Constructor | Description |
---|---|
LocalTimeCodec() |
Modifier and Type | Method | Description |
---|---|---|
LocalTime |
decode(BsonReader reader,
DecoderContext decoderContext) |
Decodes a BSON value from the given reader into an instance of the type parameter
T . |
void |
encode(BsonWriter writer,
LocalTime value,
EncoderContext encoderContext) |
Encode an instance of the type parameter
T into a BSON value. |
Class<LocalTime> |
getEncoderClass() |
Returns the Class instance that this encodes.
|
public LocalTime decode(BsonReader reader, DecoderContext decoderContext)
Decoder
T
.reader
- the BSON readerdecoderContext
- the decoder contextT
.public void encode(BsonWriter writer, LocalTime value, EncoderContext encoderContext)
T
into a BSON value.
Converts the LocalTime
to ZoneOffset.UTC
at EpochDay via LocalTime.atDate(LocalDate)
and
ChronoLocalDateTime.toInstant(ZoneOffset)
.
writer
- the BSON writer to encode intovalue
- the value to encodeencoderContext
- the encoder context