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