List of usage examples for java.text NumberFormat getNumberInstance
public static final NumberFormat getNumberInstance()
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * @inheritDoc/*from w w w.ja v a 2 s . co m*/ */ public L10NManager getLocalizationManager() { if (l10n == null) { Locale l = Locale.getDefault(); l10n = new L10NManager(l.getLanguage(), l.getCountry()) { public double parseDouble(String localeFormattedDecimal) { try { return NumberFormat.getNumberInstance().parse(localeFormattedDecimal).doubleValue(); } catch (ParseException err) { return Double.parseDouble(localeFormattedDecimal); } } public String format(int number) { return NumberFormat.getNumberInstance().format(number); } public String format(double number) { return NumberFormat.getNumberInstance().format(number); } public String formatCurrency(double currency) { return NumberFormat.getCurrencyInstance().format(currency); } public String formatDateLongStyle(Date d) { return DateFormat.getDateInstance(DateFormat.LONG).format(d); } public String formatDateShortStyle(Date d) { return DateFormat.getDateInstance(DateFormat.SHORT).format(d); } public String formatDateTime(Date d) { return DateFormat.getDateTimeInstance().format(d); } public String formatDateTimeMedium(Date d) { DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); return dd.format(d); } public String formatDateTimeShort(Date d) { DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); return dd.format(d); } public String getCurrencySymbol() { return NumberFormat.getInstance().getCurrency().getSymbol(); } public void setLocale(String locale, String language) { super.setLocale(locale, language); Locale l = new Locale(language, locale); Locale.setDefault(l); } }; } return l10n; }