Baran Topal

Baran Topal


May 2024
M T W T F S S
« Feb    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories


formatting thousand and decimal separator in Java

baranbaran

One time in past, I needed to have decimal separator as dot and thousand separator as space for a string in Java.

E.g.
134523423 should produce 1 345 234.23

So my solution was:


DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
symbols.setGroupingSeperator(' ');
DecimalFormat df = new DecimalFormat("###,##.##", symbols);
String output = df.format(1345234.23,)