use of com.torodb.kvdocument.values.heap.LongKvInstant in project torodb by torodb.
the class MapToKvValueConverter method parseDate.
private KvInstant parseDate(String key, Object value) {
if ("$date".equals(key) && value instanceof String) {
try {
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX");
TemporalAccessor date = sdf.parse((String) value);
return new InstantKvInstant(Instant.from(date));
} catch (DateTimeParseException e) {
throw new RuntimeException("Unexpected error parsing date", e);
}
}
if ("$date".equals(key) && value instanceof Long) {
return new LongKvInstant((Long) value);
}
if ("$date".equals(key) && value instanceof Double) {
return new LongKvInstant(((Double) value).longValue());
}
throw new RuntimeException("Unexpected date object type: " + key);
}
Aggregations