Skip to content

Commit 1dd9e69

Browse files
authored
(v2.17.4) Add test against #124 (#329)
1 parent d9b51aa commit 1dd9e69

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

release-notes/VERSION-2.x

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ Modules:
1010

1111
2.18.0 (not yet released)
1212

13-
No changes since 2.17
13+
2.17.4 (not yet released)
14+
15+
#124 Issue serializing and deserializing `LocalDateTime.MAX` and `LocalDateTime.MIN`
16+
(reported by @bachilast)
17+
(fix verified by Joo-Hyuk K)
1418

1519
2.17.3 (01-Nov-2024)
1620
2.17.2 (05-Jul-2024)

0 commit comments

Comments
 (0)