Skip to content

Commit

Permalink
privatize datetimeformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
yue9944882 committed Jan 7, 2021
1 parent 36ec405 commit 61cf85c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class JSON {

private boolean isLenientOnJson = false;

public static final DateTimeFormatter RFC3339MICRO_FORMATTER =
private static final DateTimeFormatter RFC3339MICRO_FORMATTER =
new DateTimeFormatterBuilder()
.parseDefaulting(ChronoField.OFFSET_SECONDS, 0)
.append(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ public void testOffsetDateTime1e3Parse() {

@Test
public void testOffsetDateTimeNoFractionParse() {
String timeStr = "2018-04-03T11:32:26Z";
OffsetDateTime t = OffsetDateTime.parse(timeStr, JSON.RFC3339MICRO_FORMATTER);
String serializedTsStr = JSON.RFC3339MICRO_FORMATTER.format(t);
assertEquals("2018-04-03T11:32:26.000000Z", serializedTsStr);
String timeStr = "\"2018-04-03T11:32:26Z\"";
OffsetDateTime dateTime = json.deserialize(timeStr, OffsetDateTime.class);
String serializedTsStr = json.serialize(dateTime);
String expectedStr = "\"2018-04-03T11:32:26.000000Z\"";
assertEquals(expectedStr, serializedTsStr);
}
}

0 comments on commit 61cf85c

Please sign in to comment.