I am trying to do a fairly simple thing using the Blackberry RIM API. I have a string of 1000000 that I want to format to 1,000,000.00
I tried two RIM API classes to do this, but none of them did what I really needed:
1) javax.microedition.global.Formatter
String value = "1000000"; float floatValue = Float.parseFloat(value); Formatter f = new Formatter();
The resulting variable is 1000000.00 - it has a decimal separator, but there are no group separators (commas).
2) net.rim.device.api.i18n.MessageFormat (claims to be compatible with java.text.MessageFormat in the standard version of Java)
String value = "1000000"; Object[] objs = {value}; MessageFormat mfPlain = new MessageFormat("{0}"); MessageFormat mfWithFormat = new MessageFormat("{0,number,###,###.##}"); String result1 = mfPlain.format(objs); String result2 = mfWithFormat.format(objs);
result1: (when the mfWithFormat code mfWithFormat commented out) it gives me just the usual 1000000 (as expected, but useless). result2: throws IllegalArgumentException .
At this moment, I have no options what to try next ...
Any suggestions?
source share