Hello I would like to use DecimalFormat to display:
8392472
as
839 24 72
I have tried
DecimalFormat dc = new DecimalFormat("000 00 00");
return dc.format(number);
I have also tried "### ## ##"
I don't think you can do that with a DecimalFormat
because your spaces are not group or decimal separators.
The simple way would be to simply use a string:
int number = 8392472;
String s = String.valueOf(number);
String formatted = s.substring(0, 3) + " "
+ s.substring(3, 5) + " "
+ s.substring(5, 7);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With