@@ -675,6 +675,29 @@ public void testStrictCustomFormatForValidDateAndTimeWithoutEra() throws Excepti
675675 assertEquals (w .value , LocalDateTime .of (2019 , 11 , 30 , 20 , 45 ));
676676 }
677677
678+ // [datatype-jsr310#124] Issue serializing and deserializing LocalDateTime.MAX and LocalDateTime.MIN
679+ @ Test
680+ public void testDeserializationOfLocalDateTimeMax () throws Exception
681+ {
682+ ObjectMapper enabledMapper = mapperBuilder ()
683+ .enable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS ).build ();
684+ _testLocalDateTimeRoundTrip (enabledMapper , LocalDateTime .MAX );
685+ _testLocalDateTimeRoundTrip (enabledMapper , LocalDateTime .MIN );
686+
687+ ObjectMapper disabledMapper = mapperBuilder ()
688+ .disable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS ).build ();
689+ _testLocalDateTimeRoundTrip (disabledMapper , LocalDateTime .MAX );
690+ _testLocalDateTimeRoundTrip (disabledMapper , LocalDateTime .MIN );
691+ }
692+
693+ private void _testLocalDateTimeRoundTrip (ObjectMapper mapper , LocalDateTime localDateTime )
694+ throws Exception
695+ {
696+ String ser = mapper .writeValueAsString (localDateTime );
697+ LocalDateTime result = mapper .readValue (ser , LocalDateTime .class );
698+ assertEquals (localDateTime , result );
699+ }
700+
678701 private void expectSuccess (ObjectReader reader , Object exp , String json ) throws IOException {
679702 final LocalDateTime value = reader .readValue (a2q (json ));
680703 assertNotNull ("The value should not be null." , value );
0 commit comments