use of com.baeldung.jackson.date.EventWithLocalDateTime in project tutorials by eugenp.
the class JacksonDateUnitTest method whenSerializingJava8DateWithCustomSerializer_thenCorrect.
@Test
public void whenSerializingJava8DateWithCustomSerializer_thenCorrect() throws JsonProcessingException {
final LocalDateTime date = LocalDateTime.of(2014, 12, 20, 2, 30);
final EventWithLocalDateTime event = new EventWithLocalDateTime("party", date);
final ObjectMapper mapper = new ObjectMapper();
final String result = mapper.writeValueAsString(event);
assertThat(result, containsString("2014-12-20 02:30"));
}
Aggregations