Search code examples
javaandroidlocalecurrency

Currency formatting using Western digits


I need to be able to display currency amounts where the currency is of the user's preferred locale, but using only Western digits. For example, if the user's chosen locale for the currency is ar_AE (for the United Arab Emirates) then the amount should be displayed as

AED 1,234.56

or something similar, using the correct currency name and number of decimal places, but using Western digits.

At the moment, I'm using NumberFormat.getCurrencyInstance(locale) which formats the text using Arabic glyphs.

What options do I have? I'm looking for a general solution which won't require me to have specific knowledge of any given currency.


Solution

  • If you want a currency formatter with number formatting according to the English locale, but using the default locale's currency, I would try something like this:

        NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.ENGLISH);
        nf.setCurrency(Currency.getInstance(Locale.getDefault()));