I want to format a BigDecimal as a currency in one Locale but use the currency symbol of another. In this particular case it's a Swedish user but the amount is in Euro.
My hope is that you can show me a better way than this:
public String getFormattedAmount()
{
Locale.setDefault(new Locale(currentUser.getLocale()));
NumberFormat nf = NumberFormat.getCurrencyInstance();
DecimalFormatSymbols decimalFormatSymbols = ((DecimalFormat) nf).getDecimalFormatSymbols();
decimalFormatSymbols.setCurrencySymbol("");
((DecimalFormat) nf).setDecimalFormatSymbols(decimalFormatSymbols);
return nf.format(amount).trim();
}
Play 2.2.