8023556: Update javadoc for start of Meiji era
authorrriggs
Sat, 14 Sep 2013 13:55:06 -0400
changeset 19861 3d5a53295b2a
parent 19860 bffc8ac408b3
child 19862 186f3a70a4f7
8023556: Update javadoc for start of Meiji era Summary: correct the javadoc in JapaneseEra.MEIJI to match the implementation Reviewed-by: darcy, sherman
jdk/src/share/classes/java/time/chrono/JapaneseEra.java
jdk/test/java/time/test/java/time/TestLocalTime.java
--- a/jdk/src/share/classes/java/time/chrono/JapaneseEra.java	Sat Sep 14 13:55:04 2013 -0400
+++ b/jdk/src/share/classes/java/time/chrono/JapaneseEra.java	Sat Sep 14 13:55:06 2013 -0400
@@ -104,7 +104,7 @@
     static final sun.util.calendar.Era[] ERA_CONFIG;
 
     /**
-     * The singleton instance for the 'Meiji' era (1868-09-08 - 1912-07-29)
+     * The singleton instance for the 'Meiji' era (1868-01-01 - 1912-07-29)
      * which has the value -1.
      */
     public static final JapaneseEra MEIJI = new JapaneseEra(-1, LocalDate.of(1868, 1, 1));
--- a/jdk/test/java/time/test/java/time/TestLocalTime.java	Sat Sep 14 13:55:04 2013 -0400
+++ b/jdk/test/java/time/test/java/time/TestLocalTime.java	Sat Sep 14 13:55:06 2013 -0400
@@ -73,6 +73,9 @@
  */
 @Test
 public class TestLocalTime extends AbstractTest {
+    static final long NANOS_PER_SECOND = 1_000_000_000L;
+    static final long NANOS_PER_MINUTE = 60 * NANOS_PER_SECOND;
+    static final long NANOS_PER_DAY = 24 * 60 * NANOS_PER_MINUTE;
 
     //-----------------------------------------------------------------------
     @Test
@@ -182,19 +185,27 @@
     // now()
     //-----------------------------------------------------------------------
     @Test
+    @SuppressWarnings("unused")
     public void now() {
         // Warmup the TimeZone data so the following test does not include
         // one-time initialization
-        LocalTime expected = LocalTime.now(Clock.systemDefaultZone());
+        LocalTime.now(Clock.systemDefaultZone());
 
-        expected = LocalTime.now(Clock.systemDefaultZone());
-        LocalTime test = LocalTime.now();
-        long diff = test.toNanoOfDay() - expected.toNanoOfDay();
-        if (diff < 0) {
-            // Adjust if for rollover around midnight
-            diff +=  24 * 60 * 60 * 1_000_000_000L; // Nanos Per Day
+        long diff = Integer.MAX_VALUE;
+        for (int i = 0; i < 2; i++) {
+            LocalTime expected = LocalTime.now(Clock.systemDefaultZone());
+            LocalTime test = LocalTime.now();
+            diff = test.toNanoOfDay() - expected.toNanoOfDay();
+            // Normalize for wrap-around midnight
+            diff = Math.floorMod(NANOS_PER_DAY + diff, NANOS_PER_DAY);
+            if (diff < 100000000) {
+                break;
+            }
+            // A second iteration may be needed if the clock changed
+            // due to a DST change between the two calls to now.
         }
-        assertTrue(diff < 500000000);  // less than 0.5 secs
+        assertTrue(diff < 100000000,   // less than 0.1 sec
+                "LocalTime.now  vs LocalTime.now(Clock.systemDefaultZone()) not close");
     }
 
 }