Class LocalTimeCodec

  • All Implemented Interfaces:
    >, >, >

    public class LocalTimeCodec
    extends 
    LocalTime Codec.

    Encodes and decodes LocalTime objects to and from DateTime. Data is stored to millisecond accuracy.

    Converts the LocalTime values to and from EpochDay at .

    Note: Requires Java 8 or greater.

    Since:
    3.7
    MongoDB documentation
    • Constructor Detail

      • LocalTimeCodec

        public LocalTimeCodec()
    • Method Detail

      • decode

        public  decode​(BsonReader reader,
                                DecoderContext decoderContext)
        Description copied from interface: Decoder
        Decodes a BSON value from the given reader into an instance of the type parameter T.
        Parameters:
        reader - the BSON reader
        decoderContext - the decoder context
        Returns:
        an instance of the type parameter T.
      • encode

        public void encode​(BsonWriter writer,
                            value,
                           EncoderContext encoderContext)
        Encode an instance of the type parameter T into a BSON value.

        Converts the LocalTime to at EpochDay via and .

        Parameters:
        writer - the BSON writer to encode into
        value - the value to encode
        encoderContext - the encoder context
      • getEncoderClass

        public <> getEncoderClass()
        Description copied from interface: Encoder
        Returns the Class instance that this encodes. This is necessary because Java does not reify generic types.
        Returns:
        the Class instance that this encodes.