logln("df type: " + df.getClass().getName() + " loc: " + df.getLocale(ULocale.VALID_LOCALE));
Calendar cal = df.getCalendar();
- // todo, what about variants of calendars, we have a type for islamic-civil, should we also have a type
- // for variants of other calendars?
- assertEquals("calendar types", cal.getType(), calTypes[i].equals("islamic-civil") ? "islamic" : calTypes[i]);
+ assertEquals("calendar types", cal.getType(), calTypes[i]);
DateFormat df2 = cal.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, ULocale.US);
logln("df2 type: " + df2.getClass().getName() + " loc: " + df2.getLocale(ULocale.VALID_LOCALE));
assertEquals("format results", df.format(time), df2.format(time));
/*
*******************************************************************************
- * Copyright (C) 1996-2011, International Business Machines Corporation and *
+ * Copyright (C) 1996-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
civilCalendar.setCivil(true);
return civilCalendar;
}
+ private static IslamicCalendar newIslamic() {
+ IslamicCalendar civilCalendar = new IslamicCalendar();
+ civilCalendar.setCivil(false);
+ return civilCalendar;
+ }
+
+ private void verifyType(Calendar c, String expectType) {
+ String theType = c.getType();
+ if(!theType.equals(expectType)) {
+ errln("Expected calendar to be type " + expectType + " but instead it is " + theType);
+ }
+ }
+ public void Test8822() {
+ verifyType(newIslamic(),"islamic");
+ verifyType(newCivil(),"islamic-civil");
+ }
}
HUNGARIAN, ITALIAN, HEBREW, JAPANESE, KOREAN, POLISH, PORTUGUESE, RUSSIAN, TURKISH,
CHINESE_SIMPLIFIED, CHINESE_TRADITIONAL };
+ String[] islamicCivilTwelfthMonthLocalized = new String[locales.length];
String[] islamicTwelfthMonthLocalized = new String[locales.length];
String[] gregorianTwelfthMonthLocalized = new String[locales.length];
Locale locale = locales[i];
// Islamic
- com.ibm.icu.util.Calendar islamicCalendar = new com.ibm.icu.util.IslamicCalendar(locale);
+ com.ibm.icu.util.Calendar islamicCivilCalendar = new com.ibm.icu.util.IslamicCalendar(locale);
+ com.ibm.icu.text.SimpleDateFormat islamicCivilDateFormat = (com.ibm.icu.text.SimpleDateFormat) islamicCivilCalendar
+ .getDateTimeFormat(com.ibm.icu.text.DateFormat.FULL, -1, locale);
+ com.ibm.icu.text.DateFormatSymbols islamicCivilDateFormatSymbols = islamicCivilDateFormat
+ .getDateFormatSymbols();
+
+ String[] shortMonthsCivil = islamicCivilDateFormatSymbols.getShortMonths();
+ String twelfthMonthLocalizedCivil = shortMonthsCivil[11];
+
+ islamicCivilTwelfthMonthLocalized[i] = twelfthMonthLocalizedCivil;
+
+ com.ibm.icu.util.IslamicCalendar islamicCalendar = new com.ibm.icu.util.IslamicCalendar(locale);
+ islamicCalendar.setCivil(false);
com.ibm.icu.text.SimpleDateFormat islamicDateFormat = (com.ibm.icu.text.SimpleDateFormat) islamicCalendar
.getDateTimeFormat(com.ibm.icu.text.DateFormat.FULL, -1, locale);
com.ibm.icu.text.DateFormatSymbols islamicDateFormatSymbols = islamicDateFormat
}
+ boolean skipIn8822 = isICUVersionBefore(50, 0, 2);
+ if(skipIn8822) {
+ logln("Note: some tests timebombed to go off by 50m2");
+ }
+
// Compare
for (int i = 0; i < locales.length; i++) {
String gregorianTwelfthMonth = gregorianTwelfthMonthLocalized[i];
+ String islamicCivilTwelfthMonth = islamicCivilTwelfthMonthLocalized[i];
String islamicTwelfthMonth = islamicTwelfthMonthLocalized[i];
- logln(locales[i] + ": " + gregorianTwelfthMonth + ", " + islamicTwelfthMonth);
+ logln(locales[i] + ": g:" + gregorianTwelfthMonth + ", ic:" + islamicCivilTwelfthMonth + ", i:"+islamicTwelfthMonth);
if (gregorianTwelfthMonth.equalsIgnoreCase(islamicTwelfthMonth)) {
errln(locales[i] + ": gregorian and islamic are same: " + gregorianTwelfthMonth
+ ", " + islamicTwelfthMonth);
}
+
+ if (gregorianTwelfthMonth.equalsIgnoreCase(islamicCivilTwelfthMonth)) {
+ if(!skipIn8822) {
+ errln(locales[i] + ": gregorian and islamic-civil are same: " + gregorianTwelfthMonth
+ + ", " + islamicCivilTwelfthMonth);
+ } else {
+ logln(locales[i] + ": gregorian and islamic-civil are same: " + gregorianTwelfthMonth
+ + ", " + islamicCivilTwelfthMonth + " (TIMEBOMBED until ICU 50.0.2)");
+ }
+ }
+ if (!islamicTwelfthMonth.equalsIgnoreCase(islamicCivilTwelfthMonth)) {
+ if(!skipIn8822) {
+ errln(locales[i] + ": islamic-civil and islamic are NOT same: " + islamicCivilTwelfthMonth
+ + ", " + islamicTwelfthMonth);
+ } else {
+ logln(locales[i] + ": islamic-civil and islamic are NOT same: " + islamicCivilTwelfthMonth
+ + ", " + islamicTwelfthMonth + " (TIMEBOMBED until 50.0.2)");
+ }
+ }
}
}