@ThreadSafe @Immutable public final class LocalTimeAttributeConverter extends Object implements AttributeConverter<LocalTime>
LocalTime
and AttributeValue
.
This stores and reads values in DynamoDB as a String.
LocalTimes are stored in the official LocalTime
format "HH:II:SS[.NNNNNNNNN]", where:
LocalTime
for more details on the serialization format.
This serialization is lexicographically orderable.
Examples:
LocalTime.of(5, 30, 0)
is stored as an AttributeValue with the String "05:30"LocalTime.of(5, 30, 0, 1)
is stored as an AttributeValue with the String "05:30:00.000000001"
This can be created via create()
.
Modifier and Type | Method and Description |
---|---|
AttributeValueType |
attributeValueType()
The
AttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class. |
static LocalTimeAttributeConverter |
create() |
AttributeValue |
transformFrom(LocalTime input)
Convert the provided Java object into an
AttributeValue . |
LocalTime |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<LocalTime> |
type()
The type supported by this converter.
|
public static LocalTimeAttributeConverter create()
public EnhancedType<LocalTime> type()
AttributeConverter
type
in interface AttributeConverter<LocalTime>
public AttributeValueType attributeValueType()
AttributeConverter
AttributeValueType
that a converter stores and reads values
from DynamoDB via the AttributeValue
class.attributeValueType
in interface AttributeConverter<LocalTime>
public AttributeValue transformFrom(LocalTime input)
AttributeConverter
AttributeValue
. This will raise a RuntimeException
if the
conversion fails, or the input is null.
Example:
InstantAsStringAttributeConverter converter = InstantAsStringAttributeConverter.create();
assertEquals(converter.transformFrom(Instant.EPOCH),
EnhancedAttributeValue.fromString("1970-01-01T00:00:00Z").toAttributeValue());
transformFrom
in interface AttributeConverter<LocalTime>
public LocalTime transformTo(AttributeValue input)
AttributeConverter
AttributeValue
into a Java object. This will raise a RuntimeException
if the
conversion fails, or the input is null.
Example:
InstantAsStringAttributeConverter converter = InstantAsStringAttributeConverter.create();
assertEquals(converter.transformTo(EnhancedAttributeValue.fromString("1970-01-01T00:00:00Z").toAttributeValue()),
Instant.EPOCH);
transformTo
in interface AttributeConverter<LocalTime>
Copyright © 2023. All rights reserved.