11/*
2- * Copyright (c) 2012, 2013 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2012, 2020 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -257,14 +257,8 @@ public void now_ZoneId() {
257257 ZoneId zone = ZoneId .of ("UTC+01:02:03" );
258258 ZonedDateTime expected = ZonedDateTime .now (Clock .system (zone ));
259259 ZonedDateTime test = ZonedDateTime .now (zone );
260- for (int i = 0 ; i < 100 ; i ++) {
261- if (expected .equals (test )) {
262- return ;
263- }
264- expected = ZonedDateTime .now (Clock .system (zone ));
265- test = ZonedDateTime .now (zone );
266- }
267- assertEquals (test , expected );
260+ assertEquals (Duration .between (expected , test ).truncatedTo (ChronoUnit .SECONDS ),
261+ Duration .ZERO );
268262 }
269263
270264 //-----------------------------------------------------------------------
@@ -755,7 +749,7 @@ public static Object[][] data_parseAdditional() {
755749 {"2012-06-30T12:30:40Z[GMT]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "GMT" },
756750 {"2012-06-30T12:30:40Z[UT]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "UT" },
757751 {"2012-06-30T12:30:40Z[UTC]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "UTC" },
758- {"2012-06-30T12:30:40+01:00[Z]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "Z" },
752+ {"2012-06-30T12:30:40+01:00[Z]" , 2012 , 6 , 30 , 11 , 30 , 40 , 0 , "Z" },
759753 {"2012-06-30T12:30:40+01:00[+01:00]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "+01:00" },
760754 {"2012-06-30T12:30:40+01:00[GMT+01:00]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "GMT+01:00" },
761755 {"2012-06-30T12:30:40+01:00[UT+01:00]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "UT+01:00" },
@@ -765,18 +759,18 @@ public static Object[][] data_parseAdditional() {
765759 {"2012-06-30T12:30:40-01:00[UT-01:00]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "UT-01:00" },
766760 {"2012-06-30T12:30:40-01:00[UTC-01:00]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "UTC-01:00" },
767761 {"2012-06-30T12:30:40+01:00[Europe/London]" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "Europe/London" },
762+ {"2012-06-30T12:30:40+01" , 2012 , 6 , 30 , 12 , 30 , 40 , 0 , "+01:00" },
768763 };
769764 }
770765
771- //TODO(b/309715638): fix the matching error.
772766 @ Test ()
773767 @ UseDataProvider ("data_parseAdditional" )
774768 public void test_parseAdditional (String text , int y , int month , int d , int h , int m , int s , int n , String zoneId ) {
775769 ZonedDateTime t = ZonedDateTime .parse (text );
776770 assertEquals (t .getYear (), y );
777771 assertEquals (t .getMonth ().getValue (), month );
778772 assertEquals (t .getDayOfMonth (), d );
779- // assertEquals(t.getHour(), h); //Expected 11 but was 12
773+ assertEquals (t .getHour (), h );
780774 assertEquals (t .getMinute (), m );
781775 assertEquals (t .getSecond (), s );
782776 assertEquals (t .getNano (), n );
@@ -2478,4 +2472,4 @@ private static ZonedDateTime dateTime(
24782472 return ZonedDateTime .ofStrict (LocalDateTime .of (year , month , dayOfMonth , hour , minute , second , nanoOfSecond ), offset , zoneId );
24792473 }
24802474
2481- }
2475+ }
0 commit comments