Class LocalDateTimeAttributeConverter

  • All Implemented Interfaces:
    AttributeConverter<LocalDateTime>

    @ThreadSafe
    @Immutable
    public final class LocalDateTimeAttributeConverter
    extends Object
    implements AttributeConverter<LocalDateTime>
    A converter between LocalDateTime and AttributeValue.

    This stores and reads values in DynamoDB as a string.

    Values are stored with nanosecond precision.

    LocalDateTimes are stored in the official LocalDateTime format "[-]YYYY-MM-DDTHH:II:SS[.NNNNNNNNN]", where:

    1. Y is a year between Year.MIN_VALUE and Year.MAX_VALUE (prefixed with - if it is negative)
    2. M is a 2-character, zero-prefixed month between 01 and 12
    3. D is a 2-character, zero-prefixed day between 01 and 31
    4. H is a 2-character, zero-prefixed hour between 00 and 23
    5. I is a 2-character, zero-prefixed minute between 00 and 59
    6. S is a 2-character, zero-prefixed second between 00 and 59
    7. N is a 9-character, zero-prefixed nanosecond between 000,000,000 and 999,999,999. The . and N may be excluded if N is 0.
    See LocalDateTime for more details on the serialization format.

    This is format-compatible with the LocalDateAttributeConverter, allowing values stored as LocalDate to be retrieved as LocalDateTimes. The time associated with a value stored as a LocalDate is the beginning of the day (midnight).

    This serialization is lexicographically orderable when the year is not negative.

    Examples:
    • LocalDateTime.of(1988, 5, 21, 0, 0, 0) is stored as an AttributeValue with the String "1988-05-21T00:00"
    • LocalDateTime.of(-1988, 5, 21, 0, 0, 0) is stored as an AttributeValue with the String "-1988-05-21T00:00"
    • LocalDateTime.of(1988, 5, 21, 0, 0, 0).plusSeconds(1) is stored as an AttributeValue with the String "1988-05-21T00:00:01"
    • LocalDateTime.of(1988, 5, 21, 0, 0, 0).minusSeconds(1) is stored as an AttributeValue with the String "1988-05-20T23:59:59"
    • LocalDateTime.of(1988, 5, 21, 0, 0, 0).plusNanos(1) is stored as an AttributeValue with the String "1988-05-21T00:00:00.0000000001"
    • LocalDateTime.of(1988, 5, 21, 0, 0, 0).minusNanos(1) is stored as an AttributeValue with the String "1988-05-20T23:59:59.999999999"

    This can be created via create().