When I use this formatter:
java.text.DecimalFormat("#.000");
for 1234567/1000000.0
output is:
1.235
I want it as like that:
1,235
and tried that:
java.text.DecimalFormat("#,000");
but it does not work as excepted. How to change dot to comma for my situation?
You need to set the format symbols using an instance of DecimalFormatSymbols:
public void testDec() {
DecimalFormat df = new DecimalFormat("#.000");
DecimalFormatSymbols sym = DecimalFormatSymbols.getInstance();
sym.setDecimalSeparator(',');
df.setDecimalFormatSymbols(sym);
System.out.println(df.format(1234567/1000000.0));
}
Output is
1,235