I have simple document with Java 8 date/time fields
@Document
public class Token {
private Instant createdAt;
...
}
that I want to persist with Spring Data MongoDB version 1.5. But fields of type java.time.Instant
could not be de-serialized correctly because MappingMongoConverter
lacks converters for java.time
classes.
In Spring 4 I found org.springframework.format.datetime.standard.DateTimeConverters
with different Converter
s including InstantToLongConverter
and LongToInstantConverter
declared as private static classes.
How can I configure MongoTemplate
to use them to map Instant
fields to longs?