Skip to content

Commit

Permalink
Merge branch '2.8' of github.com:FasterXML/jackson-modules-java8 into…
Browse files Browse the repository at this point in the history
… 2.8
  • Loading branch information
cowtowncoder committed Aug 24, 2017
2 parents 0c5bdb5 + e0eab2f commit 76b0b4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ protected ObjectMapper newMapper() {
.registerModule(new JavaTimeModule());
}

protected String quote(String value) {
return "\"" + value + "\"";
}

protected String aposToQuotes(String json) {
return json.replace("'", "\"");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;


public class TestOffsetDateTimeDeserialization extends ModuleTestBase
{
private final ObjectReader READER = newMapper().readerFor(OffsetDateTime.class);
Expand All @@ -34,6 +33,14 @@ public void testDeserializationAsString02() throws Exception
expectSuccess(OffsetDateTime.of(2000, 1, 1, 7, 0, 0, 0, ZoneOffset.UTC), "'2000-01-01T12:00+05:00'");
}

// [modules-java8#34]
@Test
public void testDeserializationWithShortFraction() throws Exception
{
expectSuccess(OffsetDateTime.of(2017, 7, 25, 20, 22, 58, 800_000_000, ZoneOffset.UTC),
quote("2017-07-25T20:22:58.8Z"));
}

@Test
public void testDeserializationAsString03() throws Exception
{
Expand All @@ -42,7 +49,6 @@ public void testDeserializationAsString03() throws Exception
//
ObjectReader reader2 = newMapper().disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE).readerFor(OffsetDateTime.class);
OffsetDateTime parsed = reader2.readValue(aposToQuotes("'2000-01-01T12:00+05:00'"));
notNull(parsed);
expect(OffsetDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.ofHours(5)), parsed) ;
}

Expand All @@ -58,7 +64,6 @@ public void testDeserializationWithContextTimezoneFeatureOverride() throws Excep
String inputStr = "{\"date\":\"2016-05-13T17:24:40.545+03\"}";
WithContextTimezoneDateFieldBean result = newMapper().setTimeZone(TimeZone.getTimeZone("UTC")).
disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE).readValue(inputStr, WithContextTimezoneDateFieldBean.class);
notNull(result);
expect(OffsetDateTime.of(2016, 5, 13, 14, 24, 40, 545000000, ZoneOffset.UTC), result.date);
}

Expand Down

0 comments on commit 76b0b4c

Please sign in to comment.