03-02-2010 02:56 PM
Where is the proper import library for the java function to set decimal places and percent signs for a number? I have googled this like crazy and cannot find where in the BB libraries it is.
Any sample code for formatting a number as a percent and setting decimal places greatly appreciated.
03-02-2010 07:17 PM
Scroll down a little on the following link and you should find what you want to accomplish:
03-02-2010 10:06 PM
you can try RIM's Formatter package, it has a method formatPercentage.
formatPercentage(float value, int decimals)
Formats a percentage with the specified number of decimals using locale-specific rules.
Formats an integral percentage value using locale-specific rules.
03-03-2010 08:21 AM
float annualdollarcoupon = (java.lang.Float.parseFloat(_efAnnualCoupon.getTex
t())); float currentprice = (java.lang.Float.parseFloat(_efPrice.getText())); javax.microedition.global.Formatter f = new javax.microedition.global.Formatter(); _lfResults.setText(f.formatPercentage((CalcLib.Cur rentYield(annualdollarcoupon, currentprice)),3));
When I try the above, I get an 'unsupported locale exception' and the app takes a dump.
Thanks for your help. What else could I be missing?
03-03-2010 08:25 AM
I think I fountd it.
My simulator had English-UK for a language. I changed to English US and it worked.
This begs a new question. How can I better handle this exception, or ensure all locales are supported?
If I published the app globally, I do not want it to break.