The grouping separator is commonly used for thousands, but in some countries it separates ten-thousands. The grouping size is a constant number of digits between the grouping characters, such as 3 for 100,000,000 or 4 for 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. So "#,##,###,####" == "######,####" == "##,####,####".
Ken Blair
Ranch Hand
Joined: Jul 15, 2003
Posts: 1078
posted
0
That's not going to help. Read the DecimalFormat documentation, specifically this excerpt:
The grouping separator is commonly used for thousands, but in some countries it separates ten-thousands. The grouping size is a constant number of digits between the grouping characters, such as 3 for 100,000,000 or 4 for 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. So "#,##,###,####" == "######,####" == "##,####,####".
It would appear that what you hope to accomplish isn't possible with DecimalFormat. The last grouping in the format is used for all groupings, if you want them to be different I guess you'll have to find one or roll your own.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
4
posted
0
I agree you aren't using a standard thousands separator format.
If all else fails, try integer division and remainder operators. But make sure you don't stray outwith the bounds of the int type:-
Or try using the Double class to change the number to a String, and split it into a char[] array, then print them one by one with commas as appropriate. You will have to count the digits in your numbers carefully for both methods otherwise you will get something like, "0,01,234.56."
Amol Juvatkar
Greenhorn
Joined: May 16, 2005
Posts: 16
posted
0
Thanks for your help.
regards Amol
Alan Moore
Ranch Hand
Joined: May 06, 2004
Posts: 262
posted
0
Here's a regex implementation of Campbell's second suggestion:
Amol Juvatkar
Greenhorn
Joined: May 16, 2005
Posts: 16
posted
0
Thanks Alan,
now one more doubt.
with statement 1 formatting doesn't work. but with statement 2 it works properly.
in general both are strings only. so what may be wrong ??
regards, amol
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.