private static String defaultPattern() { LocaleData localeData = LocaleData.get(Locale.getDefault()); return localeData.getDateFormat(SHORT) + " " + localeData.getTimeFormat(SHORT); }
private static LocaleData initLocaleData(Locale locale) { LocaleData localeData = new LocaleData(); if (!ICU.initLocaleDataNative(locale.toString(), localeData)) { throw new AssertionError("couldn't initialize LocaleData for locale " + locale);
/** * Returns a shared LocaleData for the given locale. */ public static LocaleData get(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } String localeName = locale.toString(); synchronized (localeDataCache) { LocaleData localeData = localeDataCache.get(localeName); if (localeData != null) { return localeData; } } LocaleData newLocaleData = initLocaleData(locale); synchronized (localeDataCache) { LocaleData localeData = localeDataCache.get(localeName); if (localeData != null) { return localeData; } localeDataCache.put(localeName, newLocaleData); return newLocaleData; } }
/** * Returns a {@code DateFormat} instance for formatting and parsing time * values in the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getTimeInstance(int style, Locale locale) { checkTimeStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getTimeFormat(style), locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing dates in * the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getDateInstance(int style, Locale locale) { checkDateStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getDateFormat(style), locale); }
/** * Constructs a new {@code DateFormatSymbols} instance containing the * symbols for the specified locale. * * @param locale * the locale. */ public DateFormatSymbols(Locale locale) { this.locale = locale; this.localPatternChars = SimpleDateFormat.PATTERN_CHARS; this.localeData = LocaleData.get(locale); this.ampms = localeData.amPm; this.eras = localeData.eras; this.months = localeData.longMonthNames; this.shortMonths = localeData.shortMonthNames; this.weekdays = localeData.longWeekdayNames; this.shortWeekdays = localeData.shortWeekdayNames; }
/** * Returns a {@code NumberFormat} for formatting and parsing numbers for the * specified locale. * * @param locale * the locale to use. * @return a {@code NumberFormat} for handling {@code Number} objects. */ public static NumberFormat getNumberInstance(Locale locale) { return getInstance(LocaleData.get(locale).numberPattern, locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing time * values in the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getTimeInstance(int style, Locale locale) { checkTimeStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getTimeFormat(style), locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing dates in * the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getDateInstance(int style, Locale locale) { checkDateStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getDateFormat(style), locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing dates * and time values in the specified styles for the specified locale. * * @param dateStyle * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param timeStyle * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @return the {@code DateFormat} instance for {@code dateStyle}, * {@code timeStyle} and {@code locale}. * @throws IllegalArgumentException * if {@code dateStyle} or {@code timeStyle} is not one of * SHORT, MEDIUM, LONG, FULL, or DEFAULT. */ public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) { checkTimeStyle(timeStyle); checkDateStyle(dateStyle); LocaleData localeData = LocaleData.get(locale); String pattern = localeData.getDateFormat(dateStyle) + " " + localeData.getTimeFormat(timeStyle); return new SimpleDateFormat(pattern, locale); }
/** * Returns a {@code NumberFormat} for formatting and parsing currency values * for the specified locale. * * @param locale * the locale to use. * @return a {@code NumberFormat} for handling currency values. */ public static NumberFormat getCurrencyInstance(Locale locale) { return getInstance(LocaleData.get(locale).currencyPattern, locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing time * values in the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getTimeInstance(int style, Locale locale) { checkTimeStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getTimeFormat(style), locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing dates in * the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getDateInstance(int style, Locale locale) { checkDateStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getDateFormat(style), locale); }
/** * Returns a shared LocaleData for the given locale. */ public static LocaleData get(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } String localeName = locale.toString(); synchronized (localeDataCache) { LocaleData localeData = localeDataCache.get(localeName); if (localeData != null) { return localeData; } } LocaleData newLocaleData = initLocaleData(locale); synchronized (localeDataCache) { LocaleData localeData = localeDataCache.get(localeName); if (localeData != null) { return localeData; } localeDataCache.put(localeName, newLocaleData); return newLocaleData; } }
private static LocaleData initLocaleData(Locale locale) { LocaleData localeData = new LocaleData(); if (!ICU.initLocaleDataNative(locale.toString(), localeData)) { throw new AssertionError("couldn't initialize LocaleData for locale " + locale);
private static String defaultPattern() { LocaleData localeData = LocaleData.get(Locale.getDefault()); return localeData.getDateFormat(SHORT) + " " + localeData.getTimeFormat(SHORT); }
/** * Returns a {@code NumberFormat} for formatting and parsing percentage * values for the given {@code locale}. * * <p>The {@code NumberFormat} returned by this method should only be used * to format floating-point numbers typically between 0 and 1 (with 1 being 100%). * A value such as 0.53 will be treated as 53%, but 53.0 (or the integer 53) will be * treated as 5,300%, which is rarely what you intended. */ public static NumberFormat getPercentInstance(Locale locale) { return getInstance(LocaleData.get(locale).percentPattern, locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing time * values in the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getTimeInstance(int style, Locale locale) { checkTimeStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getTimeFormat(style), locale); }
/** * Returns a {@code DateFormat} instance for formatting and parsing dates in * the specified style for the specified locale. * * @param style * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT. * @param locale * the locale. * @throws IllegalArgumentException * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or * DEFAULT. * @return the {@code DateFormat} instance for {@code style} and * {@code locale}. */ public static final DateFormat getDateInstance(int style, Locale locale) { checkDateStyle(style); return new SimpleDateFormat(LocaleData.get(locale).getDateFormat(style), locale); }
/** * Returns a shared LocaleData for the given locale. */ public static LocaleData get(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } String localeName = locale.toString(); synchronized (localeDataCache) { LocaleData localeData = localeDataCache.get(localeName); if (localeData != null) { return localeData; } } LocaleData newLocaleData = initLocaleData(locale); synchronized (localeDataCache) { LocaleData localeData = localeDataCache.get(localeName); if (localeData != null) { return localeData; } localeDataCache.put(localeName, newLocaleData); return newLocaleData; } }