From 63aa3ea44f54b01cb4a7e95d90e920e12bad5790 Mon Sep 17 00:00:00 2001 From: =?utf8?q?kaz=C3=A8de=20king?= Date: Thu, 25 Feb 2016 21:42:52 +0000 Subject: [PATCH] ICU-11872 fix build errors X-SVN-Rev: 38374 --- .../src/com/ibm/icu/impl/DayPeriodRules.java | 6 ++++- .../com/ibm/icu/text/SimpleDateFormat.java | 22 ++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/DayPeriodRules.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/DayPeriodRules.java index a9244e0dae9..0209d3293db 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/DayPeriodRules.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/DayPeriodRules.java @@ -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; } } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java index 6b23c532fe4..2ca3bcaf6c4 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java @@ -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 { -- 2.40.0