LocalDateTimeConverter implements TypeConverter<String, LocalDateTime> { @Override public LocalDateTime convert(String value) { return LocalDateTime.parse(value); }  @Override LocalDateTime convert(String value);  }
@Test public void whenInputValueIsValid_ThenShouldReturnValidLocalDateTime() { String dateTime = "2020-01-20T10:15:20"; LocalDateTime expectedDateTime = LocalDateTime.of(2020, 1, 20, 10, 15, 20); LocalDateTime convertedDateTime = converter.convert(dateTime); assertThat(convertedDateTime).isEqualTo(expectedDateTime); }
@Test(expected = DateTimeParseException.class) public void whenValueIsInvalid_ThenShouldThrowADateTimeParseException() { converter.convert("foo"); }