Java Code Examples for sun.util.locale.provider.TimeZoneNameUtility#retrieveGenericDisplayName()
The following examples show how to use
sun.util.locale.provider.TimeZoneNameUtility#retrieveGenericDisplayName() .
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: DateTimeFormatterBuilder.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 2
Source File: GenericTimeZoneNamesTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 3
Source File: DateTimeFormatterBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 4
Source File: DateTimeFormatterBuilder.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 5
Source File: GenericTimeZoneNamesTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 6
Source File: DateTimeFormatterBuilder.java From Java8CN with Apache License 2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 7
Source File: GenericTimeZoneNamesTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 8
Source File: GenericTimeZoneNamesTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 9
Source File: GenericTimeZoneNamesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 10
Source File: GenericTimeZoneNamesTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 11
Source File: DateTimeFormatterBuilder.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 12
Source File: GenericTimeZoneNamesTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 13
Source File: DateTimeFormatterBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 14
Source File: DateTimeFormatterBuilder.java From JDKSourceCode1.8 with MIT License | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 15
Source File: DateTimeFormatterBuilder.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 16
Source File: GenericTimeZoneNamesTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 17
Source File: GenericTimeZoneNamesTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 18
Source File: DateTimeFormatterBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }
Example 19
Source File: GenericTimeZoneNamesTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void test(String tzid, int style, Locale locale, String expected) { // No public API to get generic time zone names (JDK 8) String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); if (!expected.equals(got)) { System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", tzid, locale, style, got, expected); errors++; } }
Example 20
Source File: DateTimeFormatterBuilder.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private String getDisplayName(String id, int type, Locale locale) { if (textStyle == TextStyle.NARROW) { return null; } String[] names; SoftReference<Map<Locale, String[]>> ref = cache.get(id); Map<Locale, String[]> perLocale = null; if (ref == null || (perLocale = ref.get()) == null || (names = perLocale.get(locale)) == null) { names = TimeZoneNameUtility.retrieveDisplayNames(id, locale); if (names == null) { return null; } names = Arrays.copyOfRange(names, 0, 7); names[5] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } if (perLocale == null) { perLocale = new ConcurrentHashMap<>(); } perLocale.put(locale, names); cache.put(id, new SoftReference<>(perLocale)); } switch (type) { case STD: return names[textStyle.zoneNameStyleIndex() + 1]; case DST: return names[textStyle.zoneNameStyleIndex() + 3]; } return names[textStyle.zoneNameStyleIndex() + 5]; }