TESTCASE_AUTO(testTicket21222GregorianEraDiff);
TESTCASE_AUTO(testTicket21222ROCEraDiff);
TESTCASE_AUTO(testTicket21222JapaneseEraDiff);
+ TESTCASE_AUTO(testTicket21939);
TESTCASE_AUTO_END;
}
verifyCategoryAndField(formatted, expectedCategory, expectedField, status);
}
+void DateIntervalFormatTest::testTicket21939() {
+ IcuTestErrorCode err(*this, "testTicket21939");
+ LocalPointer<DateIntervalFormat> dif(DateIntervalFormat::createInstance(u"rMdhm", Locale::forLanguageTag("en-u-ca-chinese", err), err));
+
+ if (assertSuccess("Error creating DateIntervalFormat", err)) {
+ const DateFormat* df = dif->getDateFormat();
+ const SimpleDateFormat* sdf = dynamic_cast<const SimpleDateFormat*>(df);
+ UnicodeString pattern;
+ assertEquals("Wrong pattern", u"M/d/r, h:mm\u202Fa", sdf->toPattern(pattern));
+ }
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */
char ch1 = original.getFieldChar(field);
char ch2 = value.charAt(0);
if ( allowDuplicateFields ||
- (ch1 == 'r' && ch2 == 'U') ||
- (ch1 == 'U' && ch2 == 'r') ) {
+ (ch1 == 'r' && (ch2 == 'U' || ch2 == 'y')) ||
+ ((ch1 == 'U' || ch1 == 'y') && ch2 == 'r') ) {
continue;
}
throw new IllegalArgumentException("Conflicting fields:\t"
formatted.toString());
verifyFields(formatted, expectedFields);
}
+
+ @Test
+ public void testTicket21939() {
+ // the test here is just to check that this particular skeleton doesn't
+ // lead to an IllegalArgumentException
+ DateIntervalFormat dif = DateIntervalFormat.getInstance("rMdhm", ULocale.forLanguageTag("en-u-ca-chinese"));
+ DateFormat df = dif.getDateFormat();
+ SimpleDateFormat sdf = (SimpleDateFormat)df;
+ assertEquals("Wrong date format", "M/d/r, h:mm\u202Fa", sdf.toPattern());
+ }
}