DecimalFormat getFloatingPointFormatter() { if (floatingPointFormatter == null) { floatingPointFormatter = (DecimalFormat) NumberFormat.getNumberInstance(getLocale()); floatingPointFormatter.applyPattern("#,###.#"); } return floatingPointFormatter; }
} DecimalFormat getIntegerFormatter() { if (integerFormatter == null) { integerFormatter = (DecimalFormat) NumberFormat.getNumberInstance(getLocale()); integerFormatter.applyPattern("#,###"); } return integerFormatter; } DecimalFormat getPercentFormatter() { if (percentFormatter == null) { percentFormatter = (DecimalFormat) NumberFormat.getPercentInstance(getLocale()); } return percentFormatter; }
/** @return the thread local storage for the percent number formatting specific for the locale */ public static DecimalFormat getPercentFormatter() { return getFormatters().getPercentFormatter(); }
/** @return the thread local storage for the integral number formatting specific for the locale */ public static DecimalFormat getIntegerFormatter() { return getFormatters().getIntegerFormatter(); }
/** @return the thread local storage for the fixed-point number formatting specific for the locale */ public static DecimalFormat getFloatingPointFormatter() { return getFormatters().getFloatingPointFormatter(); }
/** @return the thread local storage for the currency formatting specific for the locale */ public static DecimalFormat getCurrencyFormatter() { return getFormatters().getCurrencyFormatter(); }
/** @return the locale specific date time formatter */ public static DateFormat getDateFormatter() { return getFormatters().getDateFormatter(); }
/** * @return the thread local storage for the number formatting decimal grouping separator * specific for the locale */ public static char getDecimalGroupSeparator() { return getFormatters().getDecimalGroupSeparator(); }
DecimalFormat getIntegerFormatter() { if (integerFormatter == null) { integerFormatter = (DecimalFormat) NumberFormat.getNumberInstance(getLocale()); integerFormatter.applyPattern("#,###"); } return integerFormatter; }
DateFormat getDateFormatter() { if (dateFormatter == null) { dateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.DEFAULT, getLocale()); } return dateFormatter; }
DecimalFormat getCurrencyFormatter() { if (currencyFormatter == null) { currencyFormatter = (DecimalFormat) NumberFormat.getCurrencyInstance(getLocale()); } return currencyFormatter; }
DecimalFormat getPercentFormatter() { if (percentFormatter == null) { percentFormatter = (DecimalFormat) NumberFormat.getPercentInstance(getLocale()); } return percentFormatter; }
/** * @return the current thread's initial value for this thread-local variable. This method * will be invoked at most once per accessing thread for each thread-local. */ @Override protected Object initialValue() { return new Formatters(); } }
char getDecimalGroupSeparator() { if (decimalSeparator == 0) { DecimalFormatSymbols symbols = new DecimalFormatSymbols(getLocale()); decimalSeparator = (new Character(symbols.getGroupingSeparator())).charValue(); } return decimalSeparator; }
/** * Sets the locale to apply for formatting. * * @param locale the locale to apply for formatting. */ public static void setLocale(Locale locale) { getFormatters().setLocale(locale); }
} return locale; } DecimalFormat getFloatingPointFormatter() { if (floatingPointFormatter == null) { floatingPointFormatter = (DecimalFormat) NumberFormat.getNumberInstance(getLocale()); floatingPointFormatter.applyPattern("#,###.#");
private DecimalFormat currencyFormatter; void setLocale(Locale locale) { this.locale = locale; // now all formatters need to re-created when needed, to apply the new locale floatingPointFormatter = null; integerFormatter = null; decimalSeparator = 0; dateFormatter = null; percentFormatter = null; currencyFormatter = null; } Locale getLocale() {
* * @param locale the locale to apply for formatting. */ public static void setLocale(Locale locale) { getFormatters().setLocale(locale); } /**