How to set customize currency in java?
currency, format, java, set
Solution
Try this:
NumberFormat df = NumberFormat.getCurrencyInstance();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setCurrencySymbol("$");
dfs.setGroupingSeparator('.');
dfs.setMonetaryDecimalSeparator('.');
((DecimalFormat) df).setDecimalFormatSymbols(dfs);
System.out.println(df.format(3333454));
Problem
I tried to make manual currency. Here is my code ``` DecimalFormat df = new DecimalFormat(); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setCurrencySymbol("$"); dfs.setGroupingSeparator('.'); dfs.setDecimalSeparator('.'); df.setDecimalFormatSymbols(dfs); System.out.println(df.format(3333454)); ``` Program output is 3.333.454 Why the currency symbol I set didn't appear?