public class LocalDateCodec
extends java.lang.Object
Encodes and decodes LocalDate objects to and from DateTime.
Converts the LocalDate values to and from ZoneOffset.UTC.
Note: Requires Java 8 or greater.
| Constructor and Description |
|---|
LocalDateCodec() |
| Modifier and Type | Method and Description |
|---|---|
java.time.LocalDate |
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,
java.time.LocalDate value,
EncoderContext encoderContext)
Encode an instance of the type parameter
T into a BSON value. |
java.lang.Class<java.time.LocalDate> |
getEncoderClass()
Returns the Class instance that this encodes.
|
public java.time.LocalDate decode(BsonReader reader, DecoderContext decoderContext)
DecoderT.reader - the BSON readerdecoderContext - the decoder contextT.public void encode(BsonWriter writer, java.time.LocalDate value, EncoderContext encoderContext)
T into a BSON value.
Converts the LocalDate to ZoneOffset.UTC via LocalDate.atStartOfDay(ZoneId).
writer - the BSON writer to encode intovalue - the value to encodeencoderContext - the encoder contextCodecConfigurationException - if the LocalDate cannot be converted to a valid Bson DateTime.public java.lang.Class<java.time.LocalDate> getEncoderClass()
Encoder