LocalDateTimeConverter implements AttributeConverter<LocalDateTime, Timestamp> { @Override public Timestamp convertToDatabaseColumn(LocalDateTime localDateTime) { if (null == localDateTime) { return null; } return Timestamp.valueOf(localDateTime); }  @Override Timestamp convertToDatabaseColumn(LocalDateTime localDateTime); @Override LocalDateTime convertToEntityAttribute(Timestamp dbData);  }
@Test public void null_values_are_converted_to_null() { assertNull(new LocalDateTimeConverter().convertToDatabaseColumn(null)); }
@Test public void localdatetimes_are_converted_to_timestamps() { final LocalDateTime localDate = LocalDateTime.of(1999, APRIL, 12, 10, 12, 10, 10); Timestamp timestamp = new LocalDateTimeConverter().convertToDatabaseColumn(localDate); assertThat(timestamp, is(equalTo(Timestamp.valueOf(localDate)))); }