@ThreadSafe @Immutable public final class MonthDayAttributeConverter extends Object implements AttributeConverter<MonthDay>
MonthDay and AttributeValue.
This stores and reads values in DynamoDB as a String.
MonthDays are stored in the official MonthDay format "--MM-DD", where:
MonthDay for more details on the serialization format.
This serialization is lexicographically orderable.
Examples:
MonthDay.of(5, 21) is stored as as an AttributeValue with the String "--05-21"MonthDay.of(12, 1) is stored as as an AttributeValue with the String "--12-01"
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 MonthDayAttributeConverter |
create() |
AttributeValue |
transformFrom(MonthDay input)
Convert the provided Java object into an
AttributeValue. |
MonthDay |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<MonthDay> |
type()
The type supported by this converter.
|
public static MonthDayAttributeConverter create()
public EnhancedType<MonthDay> type()
AttributeConvertertype in interface AttributeConverter<MonthDay>public AttributeValueType attributeValueType()
AttributeConverterAttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class.attributeValueType in interface AttributeConverter<MonthDay>public AttributeValue transformFrom(MonthDay input)
AttributeConverterAttributeValue. 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<MonthDay>public MonthDay transformTo(AttributeValue input)
AttributeConverterAttributeValue 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<MonthDay>Copyright © 2023. All rights reserved.