H
hulkko123
Hello,
I have String containing only numbers and a comma in followin format
nnnnnnnnn,n where n is number 0 - 9.
E.g. the right value would be 121231234,1
I have to convert it into format 12 123 1234,1
How should I code it properly using Java's Formatter classes?
I can code that using loops etc. but I do not want to code such
code. So, anyone know how to do it with formatters. I have to support
JDK 1.4.
I tried a code below, but spaces in the last line does not appear
between
numbers. I know that might approach can also be wrong.
Could someone please, how handle this formatting nicely.
String s = "121231234,1";
double d = Double.parseDouble(s);
DecimalFormat df = new DecimalFormat("## ### ####.0");
System.out.println(String.format("## ### ####.0", d));
// Output is still 121231234,1 but I would like have
// it in form 12 123 1234,1
Cheers!
I have String containing only numbers and a comma in followin format
nnnnnnnnn,n where n is number 0 - 9.
E.g. the right value would be 121231234,1
I have to convert it into format 12 123 1234,1
How should I code it properly using Java's Formatter classes?
I can code that using loops etc. but I do not want to code such
code. So, anyone know how to do it with formatters. I have to support
JDK 1.4.
I tried a code below, but spaces in the last line does not appear
between
numbers. I know that might approach can also be wrong.
Could someone please, how handle this formatting nicely.
String s = "121231234,1";
double d = Double.parseDouble(s);
DecimalFormat df = new DecimalFormat("## ### ####.0");
System.out.println(String.format("## ### ####.0", d));
// Output is still 121231234,1 but I would like have
// it in form 12 123 1234,1
Cheers!