]> granicus.if.org Git - icu/commitdiff
ICU-11872 fix build errors
authorkazède king <kazede@google.com>
Thu, 25 Feb 2016 21:42:52 +0000 (21:42 +0000)
committerkazède king <kazede@google.com>
Thu, 25 Feb 2016 21:42:52 +0000 (21:42 +0000)
X-SVN-Rev: 38374

icu4j/main/classes/core/src/com/ibm/icu/impl/DayPeriodRules.java
icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java

index a9244e0dae9f439af7aae7a6766b30d6dd60e323..0209d3293dbb76cf9e7e597f4f88d836b3d0a48f 100644 (file)
@@ -23,7 +23,9 @@ public final class DayPeriodRules {
         MORNING2,
         AFTERNOON2,
         EVENING2,
-        NIGHT2;
+        NIGHT2,
+        AM,
+        PM;
 
         public static DayPeriod[] VALUES = DayPeriod.values();
 
@@ -38,6 +40,8 @@ public final class DayPeriodRules {
             if ("afternoon2".contentEquals(str)) { return AFTERNOON2; }
             if ("evening2".contentEquals(str)) { return EVENING2; }
             if ("night2".contentEquals(str)) { return NIGHT2; }
+            if ("am".contentEquals(str)) { return AM; }
+            if ("pm".contentEquals(str)) { return PM; }
             return null;
         }
     }
index 6b23c532fe4afdcb3606d80a5c72740fb44215f0..2ca3bcaf6c41f37f83b0e21a00c84333aa6565f8 100644 (file)
@@ -1930,16 +1930,20 @@ public class SimpleDateFormat extends DateFormat {
             // Get localized string.
             assert(periodType != null);
             String toAppend = null;
+            int index;
 
-            int index = periodType.ordinal();
-            if (count <= 3) {
-                toAppend = formatData.abbreviatedDayPeriods[index];  // i.e. short
-            } else if (count == 4 || count > 5) {
-                toAppend = formatData.wideDayPeriods[index];
-            } else {  // count == 5
-                toAppend = formatData.narrowDayPeriods[index];
+            if (periodType != DayPeriodRules.DayPeriod.AM && periodType != DayPeriodRules.DayPeriod.PM) {
+                index = periodType.ordinal();
+                if (count <= 3) {
+                    toAppend = formatData.abbreviatedDayPeriods[index];  // i.e. short
+                } else if (count == 4 || count > 5) {
+                    toAppend = formatData.wideDayPeriods[index];
+                } else {  // count == 5
+                    toAppend = formatData.narrowDayPeriods[index];
+                }
             }
 
+
             // Fallback schedule:
             // Midnight/Noon -> General Periods -> AM/PM.
 
@@ -1960,7 +1964,9 @@ public class SimpleDateFormat extends DateFormat {
             }
 
             // General Periods -> AM/PM.
-            if (toAppend == null) {
+            if (periodType == DayPeriodRules.DayPeriod.AM ||
+                    periodType == DayPeriodRules.DayPeriod.PM ||
+                    toAppend == null) {
                 subFormat(buf, 'a', count, beginOffset, fieldNum, capitalizationContext, pos, cal);
             }
             else {