How can find out the system default currency symbol on BlackBerry?

Posted by ageektrapped on Stack Overflow See other posts from Stack Overflow or by ageektrapped
Published on 2010-05-10T16:01:44Z Indexed on 2010/05/10 16:04 UTC
Read the original article Hit count: 161

Filed under:
|
|
|

I have a need to display a currency value in my application. There doesn't seem to be an easy way to do this with the RIM API, so I'm reduced to creating my own solution (a common refrain for BlackBerry development, unfortunately)

Currently I'm using the Formatter class, from javax.microedition.locale like so

protected String formatResult(double result)
{
  try {
     Locale l = Locale.getDefaultForSystem();
     Formatter formatter = new Formatter(l.toString());
     return formatter.formatCurrency(result);
  } catch (UnsupportedLocaleException e)
  {
     return "This fails for the default locale because BlackBerry sucks";
  }      
}

I always hit the catch block in the simulator. Since this doesn't work by default on the simulator, I'm hesitant to put it in the application.

So I have two questions:

  1. Can anyone tell me if the above solution is the way to go? And how to fix it, of course.
  2. Is there a way I can retrieve the currency symbol for the current locale programmatically so I can format myself?

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about java