jdk/test/java/util/Calendar/Bug4958050.java
changeset 42159 9ab10842acf7
parent 38581 e761c1ccd13e
--- a/jdk/test/java/util/Calendar/Bug4958050.java	Wed Nov 16 17:29:14 2016 -0800
+++ b/jdk/test/java/util/Calendar/Bug4958050.java	Thu Nov 17 11:40:50 2016 +0530
@@ -29,9 +29,11 @@
 
 import java.util.Locale;
 import java.util.TimeZone;
+
 import static java.util.Calendar.*;
 
 public class Bug4958050 {
+
     static int errorCount = 0;
 
     public static void main(String[] args) {
@@ -41,87 +43,87 @@
         System.out.println("Time zone = " + cal.getTimeZone().getID());
 
         // Test the week fields
-        int[] weekFields = { WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_WEEK_IN_MONTH };
+        int[] weekFields = {WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_WEEK_IN_MONTH};
         for (int i = 0; i < weekFields.length; i++) {
             int field = weekFields[i];
             // add()
             cal.clear();
-            cal.set(1919, DECEMBER, 14-7, 23, 50, 00);
+            cal.set(1919, DECEMBER, 14 - 7, 23, 50, 00);
             cal.add(weekFields[i], +1);
             if (!cal.checkDate(1919, DECEMBER, 14)) {
-                error("1919/12/07: add("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/07: add(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
-            cal.set(1930, JUNE, 21-7);
+            cal.set(1930, JUNE, 21 - 7);
             cal.add(weekFields[i], +1);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/14: add("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1930/6/14: add(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
 
             // roll()
             cal.clear();
-            cal.set(1919, DECEMBER, 14-7, 23, 50, 00);
+            cal.set(1919, DECEMBER, 14 - 7, 23, 50, 00);
             cal.roll(weekFields[i], +1);
             if (!cal.checkDate(1919, DECEMBER, 14)) {
-                error("1919/12/07: roll("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/07: roll(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
-            cal.set(1930, JUNE, 21-7);
+            cal.set(1930, JUNE, 21 - 7);
             cal.roll(weekFields[i], +1);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/14: roll("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1930/6/14: roll(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
         }
 
         // Test the day fields
-        int[] dayFields = { DAY_OF_MONTH, DAY_OF_YEAR, DAY_OF_WEEK };
+        int[] dayFields = {DAY_OF_MONTH, DAY_OF_YEAR, DAY_OF_WEEK};
         for (int i = 0; i < dayFields.length; i++) {
             int field = dayFields[i];
             // add()
             cal.clear();
-            cal.set(1919, DECEMBER, 14-1, 23, 50, 00);
+            cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
             cal.add(field, +1);
             if (!cal.checkDate(1919, DECEMBER, 14)) {
-                error("1919/12/13: add("+cal.getFieldName(field)+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/13: add(" + Koyomi.getFieldName(field) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
             cal.set(1919, DECEMBER, 14, 00, 00, 00);
             cal.add(field, -1);
             if (!cal.checkDate(1919, DECEMBER, 13)) {
-                error("1919/12/14: add("+cal.getFieldName(field)+", -1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/14: add(" + Koyomi.getFieldName(field) + ", -1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
-            cal.set(1930, JUNE, 21-1);
+            cal.set(1930, JUNE, 21 - 1);
             cal.add(field, +1);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/20: add("+cal.getFieldName(field)+", +1)\n"
-                      + cal.getMessage() + cal.toDateTimeString());
+                error("1930/6/20: add(" + Koyomi.getFieldName(field) + ", +1)\n"
+                        + cal.getMessage() + cal.toDateTimeString());
             }
             cal.clear();
             cal.set(1930, JUNE, 21, 01, 00, 00);
             cal.add(field, -1);
             if (!cal.checkDateTime(1930, JUNE, 20, 01, 00, 00, 000)) {
-                error("1930/6/21: add("+cal.getFieldName(field)+", -1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1930/6/21: add(" + Koyomi.getFieldName(field) + ", -1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
 
             // roll()
             cal.clear();
-            cal.set(1930, JUNE, 21-1);
+            cal.set(1930, JUNE, 21 - 1);
             int amount = +1;
             if (field == DAY_OF_WEEK) {
                 amount += 700;
             }
             cal.roll(field, amount);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/20: roll("+cal.getFieldName(field)+", +"+amount+")\n"
-                      + cal.getMessage() + " " + cal.toDateTimeString());
+                error("1930/6/20: roll(" + Koyomi.getFieldName(field) + ", +" + amount + ")\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
             cal.set(1930, JUNE, 21, 01, 00, 00);
@@ -131,93 +133,93 @@
             }
             cal.roll(field, amount);
             if (!cal.checkDateTime(1930, JUNE, 20, 01, 00, 00, 000)) {
-                error("1930/6/21: roll("+cal.getFieldName(field)+", "+amount+")\n"
-                      + cal.getMessage()+" "+cal.toDateTimeString());
+                error("1930/6/21: roll(" + Koyomi.getFieldName(field) + ", " + amount + ")\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
         }
 
         // Test the AM_PM field
         // add()
         cal.clear();
-        cal.set(1919, DECEMBER, 14-1, 23, 50, 00);
+        cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
         cal.add(AM_PM, +1);
         if (!cal.checkDate(1919, DECEMBER, 14)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1919/12/13: add(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-1, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 1, 12, 00, 00);
         cal.add(AM_PM, +1);
         if (!cal.checkDate(1930, JUNE, 21)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/20: add(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-2, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 2, 12, 00, 00);
         cal.add(AM_PM, +3);
         if (!cal.checkDate(1930, JUNE, 21)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/10: add(AM_PM, +3)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
         cal.set(1919, DECEMBER, 14, 11, 50, 00);
         cal.add(AM_PM, -1);
-        if (!cal.checkDateTime(1919, DECEMBER, 14-1, 23, 50, 00, 000)
-            || !cal.checkFieldValue(AM_PM, PM)) {
+        if (!cal.checkDateTime(1919, DECEMBER, 14 - 1, 23, 50, 00, 000)
+                || !cal.checkFieldValue(AM_PM, PM)) {
             error("1919/12/14 11:50:00: add(AM_PM, -1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
         cal.set(1930, JUNE, 21, 01, 00, 00);
         cal.add(AM_PM, -1);
-        if (!cal.checkDateTime(1930, JUNE, 21-1, 01+12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, PM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 1, 01 + 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, PM)) {
             error("1930/6/20: add(AM_PM, -1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
         cal.set(1930, JUNE, 21, 01, 00, 00);
         cal.add(AM_PM, -3);
-        if (!cal.checkDateTime(1930, JUNE, 21-2, 01+12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, PM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 2, 01 + 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, PM)) {
             error("1930/6/10: add(AM_PM, -3)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         // roll() (should NOT change the date)
         cal.clear();
-        cal.set(1919, DECEMBER, 14-1, 23, 50, 00);
+        cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
         cal.roll(AM_PM, +1);
-        if (!cal.checkDateTime(1919, DECEMBER, 14-1, 23-12, 50, 00, 000)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+        if (!cal.checkDateTime(1919, DECEMBER, 14 - 1, 23 - 12, 50, 00, 000)
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1919/12/13: roll(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-1, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 1, 12, 00, 00);
         cal.roll(AM_PM, +1);
-        if (!cal.checkDateTime(1930, JUNE, 21-1, 12-12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 1, 12 - 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/20: roll(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-2, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 2, 12, 00, 00);
         cal.roll(AM_PM, +3);
-        if (!cal.checkDateTime(1930, JUNE, 21-2, 12-12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 2, 12 - 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/10: roll(AM_PM, +3)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         // Test the HOUR_OF_DAY field
@@ -227,7 +229,7 @@
         cal.add(HOUR_OF_DAY, +1);
         if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
             error("1930/6/20 23:00:00: add(HOUR_OF_DAY, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         // roll() (should NOT change the date)
@@ -236,7 +238,7 @@
         cal.roll(HOUR_OF_DAY, +1);
         if (!cal.checkDateTime(1930, JUNE, 20, 00, 00, 00, 000)) {
             error("1930/6/20 23:00:00: roll(HOUR_OF_DAY, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         checkErrors();