LocalDateTime converter compatible with Java SDK
LocalDateTime converter compatible with Java SDK. This was requested by a specific customer that uses both spring-data-couchbase and the Java SDK.
private CouchbaseJsr310Converters() {
...
public static Collection<Converter<?, ?>> getConvertersToRegister() {
List<Converter<?, ?>> converters = new ArrayList<>();
// converters.add(NumberToLocalDateTimeConverter.INSTANCE);
// converters.add(LocalDateTimeToLongConverter.INSTANCE);
converters.add(LocalDateTimeToStringConverter.INSTANCE);
converters.add(StringToLocalDateTimeConverter.INSTANCE);
@ReadingConverter
public enum StringToLocalDateTimeConverter implements Converter<String, LocalDateTime> {
INSTANCE;
@Override
public LocalDateTime convert(String source) {
return source == null ? null : LocalDateTime.parse(source);
}
}
@WritingConverter
public enum LocalDateTimeToStringConverter implements Converter<LocalDateTime, String> {
INSTANCE;
@Override
public String convert(LocalDateTime source) {
return source == null ? null : source.toString();
}
}
```
It looks like this has been added.
I'm not sure about that last comment - it does NOT appear to have been added. There is still only the conversion from/to Number (not string).
It seems that adding just StringToLocal... converters would allow spring data couchbase to read what was written by the java sdk. Writing is a bit tricky, as changing the serialization to String (on write) would cause problems for older versions of spring-data-couchbase that do not have the StringToLocal... converters. On the other hand, the current situation of serializing to Number on write (maybe) causes problems for reading with the java sdk. Maybe the java sdk can deserialize Numbers to LocalDateTime etc (?).