@@ -26,6 +26,11 @@ public void timeRoundTrip() throws Exception {
26
26
Date instantSeconds = Date .from (instantNow .truncatedTo (ChronoUnit .SECONDS ));
27
27
Date instantMillis = Date .from (instantNow .truncatedTo (ChronoUnit .MILLIS ));
28
28
29
+ // if we happen to land exactly on zero milliseconds, add 1 milli
30
+ if (instantSeconds .equals (instantMillis )) {
31
+ instantMillis = Date .from (instantNow .plusMillis (1 ).truncatedTo (ChronoUnit .MILLIS ));
32
+ }
33
+
29
34
// TODO: other formats
30
35
String instantFormatSlash = formatDate (instantMillis , "yyyy/MM/dd HH:mm:ss ZZZZ" );
31
36
String instantFormatDash = formatDate (instantMillis , "yyyy-MM-dd'T'HH:mm:ss'Z'" );
@@ -40,6 +45,7 @@ public void timeRoundTrip() throws Exception {
40
45
assertThat (instantSeconds ,
41
46
equalTo (GitHub .parseDate (GitHub .printDate (instantSeconds ))));
42
47
48
+ // printDate will truncate to the nearest second, so it should not be equal
43
49
assertThat (instantMillis ,
44
50
not (equalTo (GitHub .parseDate (GitHub .printDate (instantMillis )))));
45
51
@@ -49,6 +55,7 @@ public void timeRoundTrip() throws Exception {
49
55
assertThat (instantSeconds ,
50
56
equalTo (GitHub .parseDate (instantFormatDash )));
51
57
58
+ // This parser does not truncate to the nearest second, so it will be equal
52
59
assertThat (instantMillis ,
53
60
equalTo (GitHub .parseDate (instantFormatMillis )));
54
61
0 commit comments