diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java b/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java index c6df5b7867..250c72c014 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2011, International Business Machines Corporation and * + * Copyright (C) 1996-2012, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -653,7 +653,11 @@ public class IslamicCalendar extends Calendar { * @stable ICU 3.8 */ public String getType() { - return "islamic"; + if(civil) { + return "islamic-civil"; + } else { + return "islamic"; + } } /* diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java index 25883c2175..84108cee12 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 2004-2010, International Business Machines Corporation and * + * Copyright (C) 2004-2012, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -679,8 +679,8 @@ public class GlobalizationPreferencesTest extends TestFmwk { gp1.setCalendar(ical); cal = gp1.getCalendar(); calType = cal.getType(); - if (!calType.equals("islamic")) { - errln("FAIL: Calendar type afte clone is " + calType + " Expected: islamic"); + if (!calType.equals("islamic-civil")) { // default constructed IslamicCalendar is islamic-civil + errln("FAIL: Calendar type afte clone is " + calType + " Expected: islamic-civil"); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java index 31669f99c9..b8087870b7 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java @@ -979,9 +979,7 @@ public class IBMCalendarTest extends CalendarTest { 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)); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java index b2b2496e46..2e5c0f5d86 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2011, International Business Machines Corporation and * + * Copyright (C) 1996-2012, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -276,5 +276,21 @@ public class IslamicTest extends CalendarTest { 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"); + } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java index 8cee984bce..6ca00490d3 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java @@ -1089,6 +1089,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { 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]; @@ -1097,7 +1098,19 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { 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 @@ -1123,17 +1136,42 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } + 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)"); + } + } } }