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