CustomLocalDateTimeDeserializer extends StdDeserializer<LocalDateTime> { @Override public LocalDateTime deserialize(JsonParser jsonparser, DeserializationContext context) throws IOException { String date = jsonparser.getText(); if (StringUtils.isEmpty(date)) { return null; } try { return LocalDateTime.parse(date, DateTimeFormatter.ofPattern(DATE_FORMAT)); } catch (Exception e) { throw new JsonParseException(jsonparser, "Unparseable date: \"" + date + "\". Supported format: " + DATE_FORMAT); } } CustomLocalDateTimeDeserializer();  CustomLocalDateTimeDeserializer(Class<?> vc); @Override LocalDateTime deserialize(JsonParser jsonparser, DeserializationContext context);  }
@Test public void t1_deserialize() throws IOException { Mockito.when(this.jsonParser.getText()).thenReturn("1988-10-13T12:00:00.000Z"); final LocalDateTime result = this.testee.deserialize(this.jsonParser, null); Mockito.verify(this.jsonParser, Mockito.times(1)).getText(); Assert.assertEquals(LocalDateTime.of(LocalDate.of(1988, 10, 13), LocalTime.NOON), result); }
@Test public void t1_deserializeBadDate() throws IOException { Mockito.when(this.jsonParser.getText()).thenReturn("10-13-1988"); this.thrown.expect(JsonParseException.class); this.thrown.expectMessage("Unparseable date: \"10-13-1988\". Supported format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); this.testee.deserialize(this.jsonParser, null); }