]> granicus.if.org Git - icu/commitdiff
ICU-13209 Made Islamic calendar subtype detection code case insensitive.
authorYoshito Umaoka <y.umaoka@gmail.com>
Mon, 25 Sep 2017 15:19:02 +0000 (15:19 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Mon, 25 Sep 2017 15:19:02 +0000 (15:19 +0000)
X-SVN-Rev: 40456

icu4j/main/classes/core/src/com/ibm/icu/impl/CalendarUtil.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java

index a463278ad3c583e0b047df8620ac12bf9e101c59..83da8ce778f217587f876bee9be4fe0f79ef0879 100644 (file)
@@ -8,6 +8,7 @@
  */
 package com.ibm.icu.impl;
 
+import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.TreeMap;
@@ -17,7 +18,7 @@ import com.ibm.icu.util.UResourceBundle;
 
 /**
  * Calendar utilities.
- * 
+ *
  * Date/time format service classes in com.ibm.icu.text packages
  * sometimes need to access calendar internal APIs.  But calendar
  * classes are in com.ibm.icu.util package, so the package local
@@ -40,7 +41,9 @@ public final class CalendarUtil {
     public static String getCalendarType(ULocale loc) {
         String calType = loc.getKeywordValue(CALKEY);
         if (calType != null) {
-            return calType;
+            // Convert to lower case, because getKeywordValue does not
+            // canonicalize keyword value.
+            return calType.toLowerCase(Locale.ROOT);
         }
 
         // Canonicalize, so grandfathered variant will be transformed to keywords
index ef0ddaf6495be915cfe90d7bb5fd22cd4ffde65a..0b7de191112db154f078a3d1dd10f9ad7c27f9cb 100644 (file)
@@ -1015,6 +1015,20 @@ public class IslamicTest extends CalendarTestFmwk {
             errln("non civil calc type generated - " + thisCalcType);
         }
 
+        islamicLoc = new ULocale("ar_SA@calendar=ISLAMIC-UMALQURA");
+        is_cal = new IslamicCalendar(islamicLoc);
+        thisCalcType = is_cal.getType();
+        if (!"islamic-umalqura".equalsIgnoreCase(thisCalcType)) {
+            errln("non umalqura calc type generated - " + thisCalcType);
+        }
+
+        islamicLoc = new ULocale("ar_SA@calendar=ISLAMIC-CIVIL");
+        is_cal = new IslamicCalendar(islamicLoc);
+        thisCalcType = is_cal.getType();
+        if (!"islamic-civil".equalsIgnoreCase(thisCalcType)) {
+            errln("non civil calc type generated - " + thisCalcType);
+        }
+
         islamicLoc = new ULocale("ar_SA@calendar=islamic-tbla");
         is_cal = new IslamicCalendar(islamicLoc);
         thisCalcType = is_cal.getType();