posted 20 years ago
If this is all about inputting and outputting numbers Strings using comma-separated groups of three digits, e.g. converting
12003045 <=> "12,0003,045"
then you probably don't even have to split into groups of three digits - DecimalFormat will do this for you.
If you want additional leading or trailing zeros for some reason, use '0' instead of '#' in the DecimalFormat constructor:
This will print the number as 000,012,003,045.00 if that's what you want.
Now if you really need to do something more complicated, it may still be useful to break this number into separate parts, like 12, 3, 45 - but I suspect that this won't really be necessary, as DecimalFormat can probably already do what you really need here.
"I'm not back." - Bill Harding, Twister