8000 Set millisecond field to 0 if not specified in the input of parseRfc3… · sdecima/google-http-java-client@aa48f48 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa48f48

Browse files
committed
Set millisecond field to 0 if not specified in the input of parseRfc3339.
1 parent a7b1fb6 commit aa48f48

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

google-http-client/src/main/java/com/google/api/client/util/DateTime.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public static DateTime parseRfc3339(String str) throws NumberFormatException {
216216
dateTime.set(Calendar.MILLISECOND, milliseconds);
217217
tzIndex = 23;
218218
} else {
219+
dateTime.set(Calendar.MILLISECOND, 0);
219220
tzIndex = 19;
220221
}
221222
}

google-http-client/src/test/java/com/google/api/client/util/DateTimeTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public void testParseDateTime() {
5353
assertTrue(value.isDateOnly());
5454
value = DateTime.parseRfc3339("2007-06-01T10:11:30.057");
5555
assertFalse(value.isDateOnly());
56+
value = DateTime.parseRfc3339("2007-06-01T10:11:30Z");
57+
assertEquals(0, value.getValue() % 100);
5658
}
5759

5860
private void expectExceptionForParseRfc3339(String input) {

0 commit comments

Comments
 (0)
0