< prev index next >
src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java
Print this page
rev 47733 : 8176841: Additional Unicode Language-Tag Extensions
8189134: New system properties for the default Locale extensions
Reviewed-by:
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -29,14 +29,17 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.spi.TimeZoneNameProvider;
import sun.util.calendar.ZoneInfo;
+import sun.util.cldr.CLDRLocaleProviderAdapter;
+import static sun.util.locale.provider.LocaleProviderAdapter.Type;
/**
* Utility class that deals with the localized time zone names
*
* @author Naoto Sato
@@ -150,10 +153,22 @@
} else {
return null;
}
}
+ /**
+ * Converts the time zone id from LDML's 5-letter id to tzdb's id
+ *
+ * @param shortID time zone short ID defined in LDML
+ * @return the tzdb's time zone ID
+ */
+ public static Optional<String> convertLDMLShortID(String shortID) {
+ return ((CLDRLocaleProviderAdapter)LocaleProviderAdapter.forType(Type.CLDR))
+ .getTimeZoneID(shortID)
+ .map(id -> id.replaceAll("\\s.*", ""));
+ }
+
private static String[] retrieveDisplayNamesImpl(String id, Locale locale) {
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class);
String[] names;
Map<Locale, String[]> perLocale = null;
< prev index next >