@@ -655,6 +655,29 @@ public void testStrictCustomFormatForValidDateAndTimeWithoutEra() throws Excepti
655655 assertEquals (w .value , LocalDateTime .of (2019 , 11 , 30 , 20 , 45 ));
656656 }
657657
658+ // [datatype-jsr310#124] Issue serializing and deserializing LocalDateTime.MAX and LocalDateTime.MIN
659+ @ Test
660+ public void testDeserializationOfLocalDateTimeMax () throws Exception
661+ {
662+ ObjectMapper enabledMapper = mapperBuilder ()
663+ .enable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS ).build ();
664+ _testLocalDateTimeRoundTrip (enabledMapper , LocalDateTime .MAX );
665+ _testLocalDateTimeRoundTrip (enabledMapper , LocalDateTime .MIN );
666+
667+ ObjectMapper disabledMapper = mapperBuilder ()
668+ .disable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS ).build ();
669+ _testLocalDateTimeRoundTrip (disabledMapper , LocalDateTime .MAX );
670+ _testLocalDateTimeRoundTrip (disabledMapper , LocalDateTime .MIN );
671+ }
672+
673+ private void _testLocalDateTimeRoundTrip (ObjectMapper mapper , LocalDateTime localDateTime )
674+ throws Exception
675+ {
676+ String ser = mapper .writeValueAsString (localDateTime );
677+ LocalDateTime result = mapper .readValue (ser , LocalDateTime .class );
678+ assertEquals (localDateTime , result );
679+ }
680+
658681 private void expectSuccess (ObjectReader reader , Object exp , String json ) throws IOException {
659682 final LocalDateTime value = reader .readValue (a2q (json ));
660683 assertNotNull ("The value should not be null." , value );
0 commit comments