LocalDateConverter implements AttributeConverter<LocalDate, Date> { @Override public Date convertToDatabaseColumn(LocalDate localDate) { LOGGER.finest(() -> "Converting " + localDate + " to database"); if (null == localDate) { return null; } return Date.valueOf(localDate); }  @Override Date convertToDatabaseColumn(LocalDate localDate); @Override LocalDate convertToEntityAttribute(Date date);  }
@Test public void null_values_are_converted_to_null() { assertNull(new LocalDateConverter().convertToDatabaseColumn(null)); }
@Test public void localdates_are_converted_to_simple_dates_keeping_only_the_datefields() { final LocalDate localDate = LocalDate.of(1999, APRIL, 12); Date date = new LocalDateConverter().convertToDatabaseColumn(localDate); assertThat(date, is(equalTo(Date.valueOf(localDate)))); }