MORNING2,
AFTERNOON2,
EVENING2,
- NIGHT2;
+ NIGHT2,
+ AM,
+ PM;
public static DayPeriod[] VALUES = DayPeriod.values();
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;
}
}
// 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.
}
// 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 {