Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 21, 2023
2 parents 1ce43d5 + 1033f7e commit 9cc7357
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,22 @@ static class LDTWrapper {
public LDTWrapper(LocalDateTime v) { value = v; }
}

private final ObjectMapper mapper = newMapper();
private final static ObjectMapper MAPPER = newMapper();

@Test
public void testSerializationAsTimestamp01() throws Exception
{
LocalDateTime time = LocalDateTime.of(1986, Month.JANUARY, 17, 15, 43);
String value = mapper.writeValueAsString(time);

assertNotNull("The value should not be null.", value);
assertEquals("The value is not correct.", "[1986,1,17,15,43]", value);
assertEquals("The value is not correct.", "[1986,1,17,15,43]",
MAPPER.writeValueAsString(time));
}

@Test
public void testSerializationAsTimestamp02() throws Exception
{
LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 57);
String value = mapper.writeValueAsString(time);
String value = MAPPER.writeValueAsString(time);

assertNotNull("The value should not be null.", value);
assertEquals("The value is not correct.", "[2013,8,21,9,22,57]", value);
}

Expand All @@ -68,11 +65,10 @@ public void testSerializationAsTimestamp03Nanosecond() throws Exception
{
LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57);

ObjectMapper m = newMapperBuilder()
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS)
.build();
String value = m.writeValueAsString(time);
String value = MAPPER.writer()
.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS)
.writeValueAsString(time);
assertEquals("The value is not correct.", "[2013,8,21,9,22,0,57]", value);
}

Expand Down Expand Up @@ -150,7 +146,7 @@ public void testSerializationWithFormatOverride() throws Exception
{
LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 999000);
assertEquals(a2q("{'value':'2005-11-05A22:31:05'}"),
mapper.writeValueAsString(new LDTWrapper(time)));
MAPPER.writeValueAsString(new LDTWrapper(time)));

ObjectMapper m = mapperBuilder().withConfigOverride(LocalDateTime.class,
cfg -> cfg.setFormat(JsonFormat.Value.forPattern("yyyy-MM-dd'X'HH:mm")))
Expand Down
6 changes: 6 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Modules:

-

2.16.1 (not yet released)

#288: `LocalDateTime` serialization issue with custom-configured
`LocalDateTimeSerializer`
(reported by @mklinkj)

2.16.0 (15-Nov-2023)

#263: Add `JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_TIMESTAMPS` to allow parsing
Expand Down

0 comments on commit 9cc7357

Please sign in to comment.