java.util.spi.TimeZoneNameProvider Java Examples
The following examples show how to use
java.util.spi.TimeZoneNameProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimeZoneNameUtility.java From hottub with GNU General Public License v2.0 | 6 votes |
private static String getName(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, int style, String tzid) { String value = null; switch (requestID) { case "std": value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); break; case "dst": value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); break; case "generic": value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); break; } return value; }
Example #2
Source File: TimeZoneNameUtility.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static String[][] loadZoneStrings(Locale locale) { // If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings // in order to avoid per-ID retrieval. LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale); TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider(); if (provider instanceof TimeZoneNameProviderImpl) { return ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale); } // Performs per-ID retrieval. Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs(); List<String[]> zones = new LinkedList<>(); for (String key : zoneIDs) { String[] names = retrieveDisplayNamesImpl(key, locale); if (names != null) { zones.add(names); } } String[][] zonesArray = new String[zones.size()][]; return zones.toArray(zonesArray); }
Example #3
Source File: TimeZoneNameUtility.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static String[][] loadZoneStrings(Locale locale) { // If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings // in order to avoid per-ID retrieval. LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale); TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider(); if (provider instanceof TimeZoneNameProviderImpl) { return ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale); } // Performs per-ID retrieval. Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs(); List<String[]> zones = new LinkedList<>(); for (String key : zoneIDs) { String[] names = retrieveDisplayNamesImpl(key, locale); if (names != null) { zones.add(names); } } String[][] zonesArray = new String[zones.size()][]; return zones.toArray(zonesArray); }
Example #4
Source File: TimeZoneNameUtility.java From hottub with GNU General Public License v2.0 | 6 votes |
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale, String requestID, String tzid, int style, Map<String, String> aliases) { for (Map.Entry<String, String> entry : aliases.entrySet()) { if (entry.getValue().equals(tzid)) { String alias = entry.getKey(); String name = getName(tznp, locale, requestID, style, alias); if (name != null) { return name; } name = examineAliases(tznp, locale, requestID, alias, style, aliases); if (name != null) { return name; } } } return null; }
Example #5
Source File: TimeZoneNameUtility.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static String getName(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, int style, String tzid) { String value = null; switch (requestID) { case "std": value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); break; case "dst": value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); break; case "generic": value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); break; } return value; }
Example #6
Source File: TimeZoneNameUtility.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale, String requestID, String tzid, int style, Map<String, String> aliases) { for (Map.Entry<String, String> entry : aliases.entrySet()) { if (entry.getValue().equals(tzid)) { String alias = entry.getKey(); String name = getName(tznp, locale, requestID, style, alias); if (name != null) { return name; } name = examineAliases(tznp, locale, requestID, alias, style, aliases); if (name != null) { return name; } } } return null; }
Example #7
Source File: TimeZoneNameUtility.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public String getObject(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, Object... params) { assert params.length == 2; int style = (int) params[0]; String tzid = (String) params[1]; String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); if (value == null) { Map<String, String> aliases = ZoneInfo.getAliasTable(); if (aliases != null) { String canonicalID = aliases.get(tzid); if (canonicalID != null) { value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); } if (value == null) { value = examineAliases(timeZoneNameProvider, locale, requestID, canonicalID != null ? canonicalID : tzid, style, aliases); } } } return value; }
Example #8
Source File: TimeZoneNameUtility.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static String getName(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, int style, String tzid) { String value = null; switch (requestID) { case "std": value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); break; case "dst": value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); break; case "generic": value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); break; } return value; }
Example #9
Source File: TimeZoneNameUtility.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale, String requestID, String tzid, int style, Map<String, String> aliases) { if (aliases.containsValue(tzid)) { for (Map.Entry<String, String> entry : aliases.entrySet()) { if (entry.getValue().equals(tzid)) { String alias = entry.getKey(); String name = getName(tznp, locale, requestID, style, alias); if (name != null) { return name; } name = examineAliases(tznp, locale, requestID, alias, style, aliases); if (name != null) { return name; } } } } return null; }
Example #10
Source File: TimeZoneNameUtility.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static String[][] loadZoneStrings(Locale locale) { // If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings // in order to avoid per-ID retrieval. LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale); TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider(); if (provider instanceof TimeZoneNameProviderImpl) { return ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale); } // Performs per-ID retrieval. Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs(); List<String[]> zones = new LinkedList<>(); for (String key : zoneIDs) { String[] names = retrieveDisplayNamesImpl(key, locale); if (names != null) { zones.add(names); } } String[][] zonesArray = new String[zones.size()][]; return zones.toArray(zonesArray); }
Example #11
Source File: TimeZoneNameUtility.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale, String requestID, String tzid, int style, Map<String, String> aliases) { for (Map.Entry<String, String> entry : aliases.entrySet()) { if (entry.getValue().equals(tzid)) { String alias = entry.getKey(); String name = getName(tznp, locale, requestID, style, alias); if (name != null) { return name; } name = examineAliases(tznp, locale, requestID, alias, style, aliases); if (name != null) { return name; } } } return null; }
Example #12
Source File: TimeZoneNameUtility.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale, String requestID, String tzid, int style, Map<String, String> aliases) { for (Map.Entry<String, String> entry : aliases.entrySet()) { if (entry.getValue().equals(tzid)) { String alias = entry.getKey(); String name = getName(tznp, locale, requestID, style, alias); if (name != null) { return name; } name = examineAliases(tznp, locale, requestID, alias, style, aliases); if (name != null) { return name; } } } return null; }
Example #13
Source File: TimeZoneNameUtility.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static String getName(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, int style, String tzid) { String value = null; switch (requestID) { case "std": value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); break; case "dst": value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); break; case "generic": value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); break; } return value; }
Example #14
Source File: TimeZoneNameUtility.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public String getObject(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, Object... params) { assert params.length == 2; int style = (int) params[0]; String tzid = (String) params[1]; String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); if (value == null) { Map<String, String> aliases = ZoneInfo.getAliasTable(); if (aliases != null) { String canonicalID = aliases.get(tzid); if (canonicalID != null) { value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); } if (value == null) { value = examineAliases(timeZoneNameProvider, locale, requestID, canonicalID != null ? canonicalID : tzid, style, aliases); } } } return value; }
Example #15
Source File: TimeZoneNameUtility.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public String getObject(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, Object... params) { assert params.length == 2; int style = (int) params[0]; String tzid = (String) params[1]; String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); if (value == null) { Map<String, String> aliases = ZoneInfo.getAliasTable(); if (aliases != null) { String canonicalID = aliases.get(tzid); if (canonicalID != null) { value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); } if (value == null) { value = examineAliases(timeZoneNameProvider, locale, requestID, canonicalID != null ? canonicalID : tzid, style, aliases); } } } return value; }
Example #16
Source File: TimeZoneNameUtility.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale, String requestID, String tzid, int style, Map<String, String> aliases) { for (Map.Entry<String, String> entry : aliases.entrySet()) { if (entry.getValue().equals(tzid)) { String alias = entry.getKey(); String name = getName(tznp, locale, requestID, style, alias); if (name != null) { return name; } name = examineAliases(tznp, locale, requestID, alias, style, aliases); if (name != null) { return name; } } } return null; }
Example #17
Source File: TimeZoneNameUtility.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static String getName(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, int style, String tzid) { String value = null; switch (requestID) { case "std": value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); break; case "dst": value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); break; case "generic": value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); break; } return value; }
Example #18
Source File: TimeZoneNameUtility.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static String getName(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, int style, String tzid) { String value = null; switch (requestID) { case "std": value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); break; case "dst": value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); break; case "generic": value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); break; } return value; }
Example #19
Source File: TimeZoneNameUtility.java From hottub with GNU General Public License v2.0 | 6 votes |
private static String[][] loadZoneStrings(Locale locale) { // If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings // in order to avoid per-ID retrieval. LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale); TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider(); if (provider instanceof TimeZoneNameProviderImpl) { return ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale); } // Performs per-ID retrieval. Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs(); List<String[]> zones = new LinkedList<>(); for (String key : zoneIDs) { String[] names = retrieveDisplayNamesImpl(key, locale); if (names != null) { zones.add(names); } } String[][] zonesArray = new String[zones.size()][]; return zones.toArray(zonesArray); }
Example #20
Source File: TimeZoneNameUtility.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public String getObject(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, Object... params) { assert params.length == 2; int style = (int) params[0]; String tzid = (String) params[1]; String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); if (value == null) { Map<String, String> aliases = ZoneInfo.getAliasTable(); if (aliases != null) { String canonicalID = aliases.get(tzid); if (canonicalID != null) { value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); } if (value == null) { value = examineAliases(timeZoneNameProvider, locale, requestID, canonicalID != null ? canonicalID : tzid, style, aliases); } } } return value; }
Example #21
Source File: TimeZoneNameUtility.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static String getName(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, int style, String tzid) { String value = null; switch (requestID) { case "std": value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); break; case "dst": value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); break; case "generic": value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); break; } return value; }
Example #22
Source File: TimeZoneNameUtility.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public String getObject(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, Object... params) { assert params.length == 2; int style = (int) params[0]; String tzid = (String) params[1]; String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); if (value == null) { Map<String, String> aliases = ZoneInfo.getAliasTable(); if (aliases != null) { String canonicalID = aliases.get(tzid); if (canonicalID != null) { value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); } if (value == null) { value = examineAliases(timeZoneNameProvider, locale, requestID, canonicalID != null ? canonicalID : tzid, style, aliases); } } } return value; }
Example #23
Source File: TimeZoneNameUtility.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static String[] examineAliases(TimeZoneNameProvider tznp, Locale locale, String id, Map<String, String> aliases) { if (aliases.containsValue(id)) { for (Map.Entry<String, String> entry : aliases.entrySet()) { if (entry.getValue().equals(id)) { String alias = entry.getKey(); String[] names = buildZoneStrings(tznp, locale, alias); if (names != null) { return names; } names = examineAliases(tznp, locale, alias, aliases); if (names != null) { return names; } } } } return null; }
Example #24
Source File: JRELocaleProviderAdapter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public TimeZoneNameProvider getTimeZoneNameProvider() { if (timeZoneNameProvider == null) { TimeZoneNameProvider provider = AccessController.doPrivileged( (PrivilegedAction<TimeZoneNameProvider>) () -> new TimeZoneNameProviderImpl( getAdapterType(), getLanguageTagSet("TimeZoneNames"))); synchronized (this) { if (timeZoneNameProvider == null) { timeZoneNameProvider = provider; } } } return timeZoneNameProvider; }
Example #25
Source File: TimeZoneNameUtility.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public String getObject(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, Object... params) { assert params.length == 2; int style = (int) params[0]; String tzid = (String) params[1]; String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); if (value == null) { Map<String, String> aliases = ZoneInfo.getAliasTable(); if (aliases != null) { String canonicalID = aliases.get(tzid); if (canonicalID != null) { value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); } if (value == null) { value = examineAliases(timeZoneNameProvider, locale, requestID, canonicalID != null ? canonicalID : tzid, style, aliases); } } } return value; }
Example #26
Source File: TimeZoneNameUtility.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public String getObject(TimeZoneNameProvider timeZoneNameProvider, Locale locale, String requestID, Object... params) { assert params.length == 2; int style = (int) params[0]; String tzid = (String) params[1]; String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); if (value == null) { Map<String, String> aliases = ZoneInfo.getAliasTable(); if (aliases != null) { String canonicalID = aliases.get(tzid); if (canonicalID != null) { value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); } if (value == null) { value = examineAliases(timeZoneNameProvider, locale, requestID, canonicalID != null ? canonicalID : tzid, style, aliases); } } } return value; }
Example #27
Source File: TimeZoneNameUtility.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static String[][] loadZoneStrings(Locale locale) { // If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings // in order to avoid per-ID retrieval. LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale); TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider(); if (provider instanceof TimeZoneNameProviderImpl) { return ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale); } // Performs per-ID retrieval. Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs(); List<String[]> zones = new LinkedList<>(); for (String key : zoneIDs) { String[] names = retrieveDisplayNamesImpl(key, locale); if (names != null) { zones.add(names); } } String[][] zonesArray = new String[zones.size()][]; return zones.toArray(zonesArray); }
Example #28
Source File: TimeZoneNameUtility.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static String[] buildZoneStrings(TimeZoneNameProvider tznp, Locale locale, String id) { String[] names = new String[5]; for (int i = 1; i <= 4; i ++) { names[i] = tznp.getDisplayName(id, i>=3, i%2, locale); if (names[i] == null) { switch (i) { case 1: // this id seems not localized by this provider return null; case 2: case 4: // If the display name for SHORT is not supplied, // copy the LONG name. names[i] = names[i-1]; break; case 3: // If the display name for DST is not supplied, // copy the "standard" name. names[3] = names[1]; break; } } } return names; }
Example #29
Source File: JRELocaleProviderAdapter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public TimeZoneNameProvider getTimeZoneNameProvider() { if (timeZoneNameProvider == null) { TimeZoneNameProvider provider = new TimeZoneNameProviderImpl(getAdapterType(), getLanguageTagSet("TimeZoneNames")); synchronized (this) { if (timeZoneNameProvider == null) { timeZoneNameProvider = provider; } } } return timeZoneNameProvider; }
Example #30
Source File: TimeZoneNameUtility.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static String[] retrieveDisplayNamesImpl(String id, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class); String[] names; Map<Locale, String[]> perLocale = null; SoftReference<Map<Locale, String[]>> ref = cachedDisplayNames.get(id); if (Objects.nonNull(ref)) { perLocale = ref.get(); if (Objects.nonNull(perLocale)) { names = perLocale.get(locale); if (Objects.nonNull(names)) { return names; } } } // build names array names = new String[7]; names[0] = id; for (int i = 1; i <= 6; i ++) { names[i] = pool.getLocalizedObject(TimeZoneNameGetter.INSTANCE, locale, i<5 ? (i<3 ? "std" : "dst") : "generic", i%2, id); } if (Objects.isNull(perLocale)) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); ref = new SoftReference<>(perLocale); cachedDisplayNames.put(id, ref); return names; }