@Override public DecimalFormat call() throws Exception { return (DecimalFormat) NumberFormat.getCurrencyInstance(locale); } });
@Override public SoyData apply(SoyData value, List<SoyData> args) { Locale locale = I18nUtils.parseLocale(localeStringProvider.get()); NumberFormat instance; String formatType = args.isEmpty() ? "decimal" : args.get(0).stringValue(); if (formatType.equals("decimal")) { instance = NumberFormat.getInstance(locale); } else if (formatType.equals("percent")) { instance = NumberFormat.getPercentInstance(locale); } else if (formatType.equals("currency")) { instance = NumberFormat.getCurrencyInstance(locale); } else if (formatType.equals("scientific")) { instance = NumberFormat.getScientificInstance(locale); } else { throw new IllegalArgumentException( String.format("Unrecognized Number Format Type: {0}", formatType)); } return toSoyData(StringEscapeUtils.escapeHtml4(instance.format(Float.parseFloat(value.stringValue())))); }
public CurrencyFormat(ULocale locale) { // Needed for getLocale(ULocale.VALID_LOCALE). setLocale(locale, locale); mf = MeasureFormat.getInstance(locale, FormatWidth.WIDE); fmt = NumberFormat.getCurrencyInstance(locale.toLocale()); }
@Override public Number parseCurrencyAmount(String locale, String value, String currencyCode) throws ParseException { ULocale closestLocale = localeService.getClosestULocale(locale); Currency currency; if (StringUtils.isEmpty(currencyCode)) { currency = Currency.getInstance(new ULocale(locale)); } else { currency = Currency.getInstance(currencyCode); } NumberFormat nf = NumberFormat.getCurrencyInstance(closestLocale); nf.setCurrency(currency); return nf.parse(value); }
@Override public Number parseCurrencyAmount(String locale, String value, String currencyCode) throws ParseException { ULocale closestLocale = findClosestULocale(locale); Currency currency; if (StringUtils.isEmpty(currencyCode)) { currency = Currency.getInstance(new ULocale(locale)); } else { currency = Currency.getInstance(currencyCode); } NumberFormat nf = NumberFormat.getCurrencyInstance(closestLocale); nf.setCurrency(currency); return nf.parse(value); }
@Override public String formatCurrencyAmount(String locale, Number amount, String currencyCode) { ULocale closestLocale = findClosestULocale(locale); Currency currency; if (StringUtils.isEmpty(currencyCode)) { currency = Currency.getInstance(new ULocale(locale)); } else { currency = Currency.getInstance(currencyCode); } CurrencyAmount ca = new CurrencyAmount(amount, currency); NumberFormat nf = NumberFormat.getCurrencyInstance(closestLocale); nf.setCurrency(currency); return nf.format(ca); }
@Override public String formatCurrencyAmount(String locale, Number amount, String currencyCode) { ULocale closestLocale = localeService.getClosestULocale(locale); Currency currency; if (StringUtils.isEmpty(currencyCode)) { currency = Currency.getInstance(new ULocale(locale)); } else { currency = Currency.getInstance(currencyCode); } CurrencyAmount ca = new CurrencyAmount(amount, currency); NumberFormat nf = NumberFormat.getCurrencyInstance(closestLocale); nf.setCurrency(currency); return nf.format(ca); }
/** Formats a double into a properly formatted currency string based on isoCode and Locale * @param price The price double to be formatted * @param isoCode the currency ISO code * @param locale The Locale used to format the number * @param maximumFractionDigits The maximum number of fraction digits used; if set to -1 than the default value for the locale is used * @return A String with the formatted price */ public static String formatCurrency(double price, String isoCode, Locale locale, int maximumFractionDigits) { com.ibm.icu.text.NumberFormat nf = com.ibm.icu.text.NumberFormat.getCurrencyInstance(locale); if (isoCode != null && isoCode.length() > 1) { nf.setCurrency(com.ibm.icu.util.Currency.getInstance(isoCode)); } else { if (Debug.verboseOn()) { Debug.logVerbose("No isoCode specified to format currency value:" + price, module); } } if (maximumFractionDigits >= 0) { nf.setMaximumFractionDigits(maximumFractionDigits); } return nf.format(price); }
break; case NF_CURRENCY: result = NumberFormat.getCurrencyInstance(nfLocale); result.setCurrency(getCurrency()); break;
break; case "currency": numberFormat = NumberFormat.getCurrencyInstance(uLocale); break; case "scientific":
break; case "currency": numberFormat = NumberFormat.getCurrencyInstance(uLocale); break; case "scientific":
break; case CURRENCY: icuNfmt = com.ibm.icu.text.NumberFormat.getCurrencyInstance(actual); break; case PERCENT:
break; case MODIFIER_CURRENCY: newFormat = NumberFormat.getCurrencyInstance(ulocale); break; case MODIFIER_PERCENT: