sun.util.locale.provider.LocaleResources Java Examples
The following examples show how to use
sun.util.locale.provider.LocaleResources.
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: Locale.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Returns a name for the locale's variant code that is appropriate for display to the * user. If possible, the name will be localized for inLocale. If the locale * doesn't specify a variant code, this function returns the empty string. * * @param inLocale The locale for which to retrieve the display variant code. * @return The name of the display variant code appropriate to the given locale. * @throws NullPointerException if {@code inLocale} is {@code null} */ public String getDisplayVariant(Locale inLocale) { if (baseLocale.getVariant().isEmpty()) return ""; LocaleResources lr = LocaleProviderAdapter .getResourceBundleBased() .getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, lr.getLocaleName("ListCompositionPattern")); }
Example #2
Source File: CLDRTimeZoneNameProviderImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
private String toGMTFormat(String id, boolean daylight, boolean isShort, Locale l) { TimeZone tz = ZoneInfoFile.getZoneInfo(id); int offset = (tz.getRawOffset() + (daylight ? tz.getDSTSavings() : 0)) / 60000; LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l); ResourceBundle fd = lr.getJavaTimeFormatData(); if (offset == 0) { return fd.getString("timezone.gmtZeroFormat"); } else { String gmtFormat = fd.getString("timezone.gmtFormat"); String hourFormat = fd.getString("timezone.hourFormat"); if (offset > 0) { hourFormat = hourFormat.substring(0, hourFormat.indexOf(";")); } else { hourFormat = hourFormat.substring(hourFormat.indexOf(";") + 1); offset = -offset; } hourFormat = hourFormat .replaceFirst("H+", (isShort ? "\\%1\\$d" : "\\%1\\$02d")) .replaceFirst("m+", "\\%2\\$02d"); return MessageFormat.format(gmtFormat, String.format(l, hourFormat, offset / 60, offset % 60)); } }
Example #3
Source File: JSpinner.java From Bytecoder with Apache License 2.0 | 5 votes |
private static String getDefaultPattern(Locale loc) { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc); LocaleResources lr = adapter.getLocaleResources(loc); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc); } return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null); }
Example #4
Source File: WeekFields.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } return name; }
Example #5
Source File: Locale.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns a name for the locale's variant code that is appropriate for display to the * user. If possible, the name will be localized for inLocale. If the locale * doesn't specify a variant code, this function returns the empty string. * * @param inLocale The locale for which to retrieve the display variant code. * @return The name of the display variant code appropriate to the given locale. * @exception NullPointerException if <code>inLocale</code> is <code>null</code> */ public String getDisplayVariant(Locale inLocale) { if (baseLocale.getVariant().length() == 0) return ""; LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, lr.getLocaleName("ListPattern"), lr.getLocaleName("ListCompositionPattern")); }
Example #6
Source File: WeekFields.java From Java8CN with Apache License 2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } return name; }
Example #7
Source File: DateTimeFormatterBuilder.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Gets the formatting pattern for date and time styles for a locale and chronology. * The locale and chronology are used to lookup the locale specific format * for the requested dateStyle and/or timeStyle. * * @param dateStyle the FormatStyle for the date, null for time-only pattern * @param timeStyle the FormatStyle for the time, null for date-only pattern * @param chrono the Chronology, non-null * @param locale the locale, non-null * @return the locale and Chronology specific formatting pattern * @throws IllegalArgumentException if both dateStyle and timeStyle are null */ public static String getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale) { Objects.requireNonNull(locale, "locale"); Objects.requireNonNull(chrono, "chrono"); if (dateStyle == null && timeStyle == null) { throw new IllegalArgumentException("Either dateStyle or timeStyle must be non-null"); } LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased().getLocaleResources(locale); String pattern = lr.getJavaTimeDateTimePattern( convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType()); return pattern; }
Example #8
Source File: JSpinner.java From hottub with GNU General Public License v2.0 | 5 votes |
private static String getDefaultPattern(Locale locale) { // Get the pattern for the default locale. LocaleProviderAdapter adapter; adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, locale); LocaleResources lr = adapter.getLocaleResources(locale); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); } String[] all = lr.getNumberPatterns(); return all[0]; }
Example #9
Source File: Locale.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Returns a name for the locale's variant code that is appropriate for display to the * user. If possible, the name will be localized for inLocale. If the locale * doesn't specify a variant code, this function returns the empty string. * * @param inLocale The locale for which to retrieve the display variant code. * @return The name of the display variant code appropriate to the given locale. * @exception NullPointerException if <code>inLocale</code> is <code>null</code> */ public String getDisplayVariant(Locale inLocale) { if (baseLocale.getVariant().length() == 0) return ""; LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, lr.getLocaleName("ListPattern"), lr.getLocaleName("ListCompositionPattern")); }
Example #10
Source File: JSpinner.java From Java8CN with Apache License 2.0 | 5 votes |
private static String getDefaultPattern(Locale loc) { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc); LocaleResources lr = adapter.getLocaleResources(loc); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc); } return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null); }
Example #11
Source File: JSpinner.java From Java8CN with Apache License 2.0 | 5 votes |
private static String getDefaultPattern(Locale locale) { // Get the pattern for the default locale. LocaleProviderAdapter adapter; adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, locale); LocaleResources lr = adapter.getLocaleResources(locale); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); } String[] all = lr.getNumberPatterns(); return all[0]; }
Example #12
Source File: IsoFields.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : toString(); }
Example #13
Source File: WeekFields.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } return name; }
Example #14
Source File: IsoFields.java From Java8CN with Apache License 2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : toString(); }
Example #15
Source File: WeekFields.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } return name; }
Example #16
Source File: JSpinner.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static String getDefaultPattern(Locale loc) { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc); LocaleResources lr = adapter.getLocaleResources(loc); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc); } return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null); }
Example #17
Source File: JSpinner.java From Bytecoder with Apache License 2.0 | 5 votes |
private static String getDefaultPattern(Locale locale) { // Get the pattern for the default locale. LocaleProviderAdapter adapter; adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, locale); LocaleResources lr = adapter.getLocaleResources(locale); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); } String[] all = lr.getNumberPatterns(); return all[0]; }
Example #18
Source File: Locale.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns a name for the locale's variant code that is appropriate for display to the * user. If possible, the name will be localized for inLocale. If the locale * doesn't specify a variant code, this function returns the empty string. * * @param inLocale The locale for which to retrieve the display variant code. * @return The name of the display variant code appropriate to the given locale. * @exception NullPointerException if <code>inLocale</code> is <code>null</code> */ public String getDisplayVariant(Locale inLocale) { if (baseLocale.getVariant().length() == 0) return ""; LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, lr.getLocaleName("ListPattern"), lr.getLocaleName("ListCompositionPattern")); }
Example #19
Source File: CLDRTimeZoneNameProviderImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
private boolean regionFormatFallback(String[] names, int index, Locale l) { String id = names[INDEX_TZID]; LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l); ResourceBundle fd = lr.getJavaTimeFormatData(); String rgn = (String) lr.getTimeZoneNames("timezone.excity." + id); if (rgn == null && !id.startsWith("Etc") && !id.startsWith("SystemV")) { int slash = id.lastIndexOf('/'); if (slash > 0) { rgn = id.substring(slash + 1).replaceAll("_", " "); } } if (rgn != null) { String fmt = ""; switch (index) { case INDEX_STD_LONG: fmt = fd.getString("timezone.regionFormat.standard"); break; case INDEX_DST_LONG: fmt = fd.getString("timezone.regionFormat.daylight"); break; case INDEX_GEN_LONG: fmt = fd.getString("timezone.regionFormat"); break; } if (!fmt.isEmpty()) { names[index] = MessageFormat.format(fmt, rgn); } } return exists(names, index); }
Example #20
Source File: DateTimeFormatterBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Gets the formatting pattern for date and time styles for a locale and chronology. * The locale and chronology are used to lookup the locale specific format * for the requested dateStyle and/or timeStyle. * * @param dateStyle the FormatStyle for the date * @param timeStyle the FormatStyle for the time * @param chrono the Chronology, non-null * @param locale the locale, non-null * @return the locale and Chronology specific formatting pattern * @throws IllegalArgumentException if both dateStyle and timeStyle are null */ public static String getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale) { Objects.requireNonNull(locale, "locale"); Objects.requireNonNull(chrono, "chrono"); if (dateStyle == null && timeStyle == null) { throw new IllegalArgumentException("Either dateStyle or timeStyle must be non-null"); } LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased().getLocaleResources(locale); String pattern = lr.getJavaTimeDateTimePattern( convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType()); return pattern; }
Example #21
Source File: Locale.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns a name for the locale's variant code that is appropriate for display to the * user. If possible, the name will be localized for inLocale. If the locale * doesn't specify a variant code, this function returns the empty string. * * @param inLocale The locale for which to retrieve the display variant code. * @return The name of the display variant code appropriate to the given locale. * @exception NullPointerException if <code>inLocale</code> is <code>null</code> */ public String getDisplayVariant(Locale inLocale) { if (baseLocale.getVariant().length() == 0) return ""; LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, lr.getLocaleName("ListPattern"), lr.getLocaleName("ListCompositionPattern")); }
Example #22
Source File: IsoFields.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources( CalendarDataUtility .findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : toString(); }
Example #23
Source File: JSpinner.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static String getDefaultPattern(Locale locale) { // Get the pattern for the default locale. LocaleProviderAdapter adapter; adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, locale); LocaleResources lr = adapter.getLocaleResources(locale); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); } String[] all = lr.getNumberPatterns(); return all[0]; }
Example #24
Source File: DateTimeFormatterBuilder.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Gets the formatting pattern for date and time styles for a locale and chronology. * The locale and chronology are used to lookup the locale specific format * for the requested dateStyle and/or timeStyle. * * @param dateStyle the FormatStyle for the date * @param timeStyle the FormatStyle for the time * @param chrono the Chronology, non-null * @param locale the locale, non-null * @return the locale and Chronology specific formatting pattern * @throws IllegalArgumentException if both dateStyle and timeStyle are null */ public static String getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale) { Objects.requireNonNull(locale, "locale"); Objects.requireNonNull(chrono, "chrono"); if (dateStyle == null && timeStyle == null) { throw new IllegalArgumentException("Either dateStyle or timeStyle must be non-null"); } LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased().getLocaleResources(locale); String pattern = lr.getJavaTimeDateTimePattern( convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType()); return pattern; }
Example #25
Source File: DateTimeFormatterBuilder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Gets the formatting pattern for date and time styles for a locale and chronology. * The locale and chronology are used to lookup the locale specific format * for the requested dateStyle and/or timeStyle. * * @param dateStyle the FormatStyle for the date, null for time-only pattern * @param timeStyle the FormatStyle for the time, null for date-only pattern * @param chrono the Chronology, non-null * @param locale the locale, non-null * @return the locale and Chronology specific formatting pattern * @throws IllegalArgumentException if both dateStyle and timeStyle are null */ public static String getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale) { Objects.requireNonNull(locale, "locale"); Objects.requireNonNull(chrono, "chrono"); if (dateStyle == null && timeStyle == null) { throw new IllegalArgumentException("Either dateStyle or timeStyle must be non-null"); } LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased().getLocaleResources(locale); String pattern = lr.getJavaTimeDateTimePattern( convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType()); return pattern; }
Example #26
Source File: WeekFields.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } return name; }
Example #27
Source File: IsoFields.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : toString(); }
Example #28
Source File: Locale.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Returns a name for the locale's variant code that is appropriate for display to the * user. If possible, the name will be localized for inLocale. If the locale * doesn't specify a variant code, this function returns the empty string. * * @param inLocale The locale for which to retrieve the display variant code. * @return The name of the display variant code appropriate to the given locale. * @exception NullPointerException if <code>inLocale</code> is <code>null</code> */ public String getDisplayVariant(Locale inLocale) { if (baseLocale.getVariant().length() == 0) return ""; LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, lr.getLocaleName("ListPattern"), lr.getLocaleName("ListCompositionPattern")); }
Example #29
Source File: JSpinner.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static String getDefaultPattern(Locale loc) { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc); LocaleResources lr = adapter.getLocaleResources(loc); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc); } return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null); }
Example #30
Source File: JSpinner.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static String getDefaultPattern(Locale loc) { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc); LocaleResources lr = adapter.getLocaleResources(loc); if (lr == null) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc); } return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null); }