jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java
changeset 36014 3d50784f2dc2
parent 32510 7530a468314c
child 38440 9e77c5b81def
--- a/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java	Mon Dec 28 12:16:09 2015 +0100
+++ b/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java	Fri Feb 19 09:55:37 2016 -0800
@@ -504,12 +504,22 @@
      * Examine if the id includes the country (territory) code. If it does, it returns
      * the country code.
      * Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it return "SG".
-     * For now, it does not return US M.49 code, e.g., '001', as those three digit numbers cannot
+     * It does NOT return UN M.49 code, e.g., '001', as those three digit numbers cannot
      * be translated into package names.
      */
     static String getCountryCode(String id) {
-        String ctry = Locale.forLanguageTag(id.replaceAll("_", "-")).getCountry();
-        return ctry.length() == 2 ? ctry : null;
+        String rgn = getRegionCode(id);
+        return rgn.length() == 2 ? rgn: null;
+    }
+
+    /**
+     * Examine if the id includes the region code. If it does, it returns
+     * the region code.
+     * Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it return "SG".
+     * It DOES return UN M.49 code, e.g., '001', as well as ISO 3166 two letter country codes.
+     */
+    static String getRegionCode(String id) {
+        return Locale.forLanguageTag(id.replaceAll("_", "-")).getCountry();
     }
 
     private static class KeyComparator implements Comparator<String> {