I’m trying to map to DynamoDB list of dates in Java
@DynamoDBTypeConverted(converter = LocalDateTimeConverter.class)
private List<LocalDateTime> acquisitionsDates;
public class LocalDateTimeConverter implements DynamoDBTypeConverter<String, LocalDateTime> {
@Override
public String convert(LocalDateTime dateTime) {
return dateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}
@Override
public LocalDateTime unconvert(String dateTimeStr) {
return LocalDateTime.parse(dateTimeStr);
}
}
I have written my own converter but it works only for LocalDateTime but not for the List. Does anyone know how to do it correctly?
Should I write separate converter that will return list of strings where each string will be converted from localdatetime?
2
Answers
I wrote converter like below and it works as I wanted ;)
}
In Interface DynamoDBTypeConverter<S,T> represents S – The DynamoDB standard type, T – The object’s field/property type. Use T as List.