- Formattable fmtArray[2];
- fmtArray[0].adoptString(earlierDate);
- fmtArray[1].adoptString(laterDate);
-
- UnicodeString fallback;
- MessageFormat::format(fallbackPattern, fmtArray, 2, fallback, status);
+ adjustPosition(fallbackPattern, earlierDate, pos, laterDate, otherPos, pos);
+ UnicodeString fallbackRange;
+ SimpleFormatter(fallbackPattern, 2, 2, status).
+ format(earlierDate, laterDate, fallbackRange, status);
+ if ( U_SUCCESS(status) && formatDatePlusTimeRange ) {
+ // fallbackRange has just the time range, need to format the date part and combine that
+ UnicodeString dateTimeFormatNoQuote(*fDateTimeFormat);
+ dateTimeFormatNoQuote.findAndReplace(UnicodeString(0x0027), UnicodeString());
+ fDateFormat->applyPattern(*fDatePattern);
+ UnicodeString datePortion;
+ otherPos.setBeginIndex(0);
+ otherPos.setEndIndex(0);
+ fDateFormat->format(fromCalendar, datePortion, otherPos);
+ adjustPosition(dateTimeFormatNoQuote, fallbackRange, pos, datePortion, otherPos, pos);
+ const UnicodeString *values[2] = {
+ &fallbackRange, // {0} is time range
+ &datePortion, // {1} is single date portion
+ };
+ SimpleFormatter(dateTimeFormatNoQuote, 2, 2, status).
+ formatAndReplace(values, 2, fallbackRange, NULL, 0, status);
+ }