Java8LocalDateTimeConverter extends Converter { @Override public Object toDbValue(Object value) { return Date.from(((LocalDateTime) value).atZone(ZoneId.systemDefault()).toInstant()); }  @Override Object toDbValue(Object value);  }
@Test public void canSerialize() { final Object result = new Java8LocalDateTimeConverter().toDbValue(LocalDateTime.of(2014, 1, 1, 17, 30, 20)); assertThat(result).isNotNull(); assertThat(result).isInstanceOf(Date.class); }
@Test public void operationIsSymetric() { final LocalDateTime originalDate = LocalDateTime.of(2014, 1, 1, 17, 10, 23); final Java8LocalDateTimeConverter converter = new Java8LocalDateTimeConverter(); final Object serialized = converter.toDbValue(originalDate); final Object unserialized = converter.fromDbValue(serialized); assertThat(unserialized).isEqualTo(originalDate); }