summaryrefslogtreecommitdiff
path: root/icu4j/main/classes
diff options
context:
space:
mode:
Diffstat (limited to 'icu4j/main/classes')
-rw-r--r--icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java9
-rw-r--r--icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java17
2 files changed, 19 insertions, 7 deletions
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java
index fac49a006..4c88da72e 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java
@@ -874,8 +874,13 @@ public class DateIntervalFormat extends UFormat {
otherPos.setEndIndex(0);
datePortion = fDateFormat.format(fromCalendar, datePortion, otherPos);
adjustPosition(fDateTimeFormat, fallbackRange, pos, datePortion.toString(), otherPos, pos);
- fallbackRange = SimpleFormatterImpl.formatRawPattern(
- fDateTimeFormat, 2, 2, fallbackRange, datePortion);
+ // Android patch (CLDR ticket #10321) begin.
+ MessageFormat msgFmt = new MessageFormat("");
+ msgFmt.applyPattern(fDateTimeFormat, MessagePattern.ApostropheMode.DOUBLE_REQUIRED);
+ StringBuffer fallbackRangeBuffer = new StringBuffer(128);
+ fallbackRange = msgFmt.format(new Object[] { fallbackRange, datePortion },
+ fallbackRangeBuffer, new FieldPosition(0)).toString();
+ // Android patch (CLDR ticket #10321) end.
}
appendTo.append(fallbackRange);
if (formatDatePlusTimeRange) {
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java
index bd808b46e..465c990a6 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java
@@ -8,6 +8,7 @@
*/
package com.ibm.icu.text;
+import java.text.FieldPosition;
import java.util.EnumMap;
import java.util.Locale;
@@ -456,8 +457,8 @@ public final class RelativeDateTimeFormatter {
return new RelativeDateTimeFormatter(
data.qualitativeUnitMap,
data.relUnitPatternMap,
- SimpleFormatterImpl.compileToStringMinMaxArguments(
- data.dateTimePattern, new StringBuilder(), 2, 2),
+ // Android-changed: use MessageFormat instead of SimpleFormatterImpl (b/63745717).
+ data.dateTimePattern,
PluralRules.forLocale(locale),
nf,
style,
@@ -708,8 +709,13 @@ public final class RelativeDateTimeFormatter {
* @stable ICU 53
*/
public String combineDateAndTime(String relativeDateString, String timeString) {
- return SimpleFormatterImpl.formatCompiledPattern(
- combinedDateAndTime, timeString, relativeDateString);
+ // BEGIN Android-changed: use MessageFormat instead of SimpleFormatterImpl (b/63745717).
+ MessageFormat msgFmt = new MessageFormat("");
+ msgFmt.applyPattern(combinedDateAndTime, MessagePattern.ApostropheMode.DOUBLE_REQUIRED);
+ StringBuffer combinedDateTimeBuffer = new StringBuffer(128);
+ return msgFmt.format(new Object[] { timeString, relativeDateString},
+ combinedDateTimeBuffer, new FieldPosition(0)).toString();
+ // END Android-changed: use MessageFormat instead of SimpleFormatterImpl (b/63745717).
}
/**
@@ -817,7 +823,8 @@ public final class RelativeDateTimeFormatter {
private final EnumMap<Style, EnumMap<AbsoluteUnit, EnumMap<Direction, String>>> qualitativeUnitMap;
private final EnumMap<Style, EnumMap<RelativeUnit, String[][]>> patternMap;
- private final String combinedDateAndTime; // compiled SimpleFormatter pattern
+ // Android-changed: use MessageFormat instead of SimpleFormatterImpl (b/63745717).
+ private final String combinedDateAndTime; // MessageFormat pattern for combining date and time.
private final PluralRules pluralRules;
private final NumberFormat numberFormat;