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