4

I'm getting on devices with not-english locale, the english currencies formated like this:

1 $

If I have english locale I get euro currency like:

€ 1

Using

format.setCurrency(Currency.getInstance(currency));
return format.format(amount);

Found in the documentation:

http://developer.android.com/reference/java/util/Currency.html#getSymbol()

Returns the localized currency symbol for this currency in locale. That is, given "USD" and Locale.US, you'd get "$", but given "USD" and a non-US locale, you'd get "US$".

If the locale only specifies a language rather than a language and a country (such as Locale.JAPANESE or {new Locale("en", "")} rather than Locale.JAPAN or {new Locale("en", "US")}), the ISO 4217 currency code is returned.

If there is no locale-specific currency symbol, the ISO 4217 currency code is returned.

Is not the same method but probably related. Why does it make difference the locale of my device for the symbol ordering in the currency? 1$ is incorrect no matter which locale I'm using.

Is there a way to change this?

User
  • 31,811
  • 40
  • 131
  • 232
  • Put currency symbols to your local-resource value-eng,values-fra,values-ru – Yahor10 Sep 19 '12 at 08:20
  • 2
    Writing the currency after the amount is correct in some locales. Swedish writing rules recommend this, for example. – Albin Sep 19 '12 at 08:23

1 Answers1

4

The behaviour of the method is correct.

Not all countries expect the currency symbol before the amount.

If you always want the currency format to match an Americanised expectation, leave the locale as Locale.US. If you want the currency to display in a localised way, leave your implementation as is.

See this brief guide (from Microsoft, no less):

Currency Formatting

I'd guess what you may be trying to achieve is to display the currency in a format appropriate to its locale? If that's the case, just match the locale to the currency you're using, before calling the method.

Note that the format can even vary in the same country. In Canada, it's reasonably common to see English speakers use the format $50.00, whereas French-Canadians may use 50,00 $.

Also see this question on UX:

https://ux.stackexchange.com/questions/22574/where-to-place-currency-symbol-when-localizing-and-what-to-do-with-odd-symbols

Primož Ivančič
  • 1,984
  • 1
  • 17
  • 29
Michael
  • 7,348
  • 10
  • 49
  • 86
  • Ok, so € 1 is not overall incorrect? I thought 1 € has to be always written that way (or $ 1), and that it doesn't have any relation with where it's displayed. If it's not incorrect I'll just let it at it is. Don't want to do anything special, just fix bug, if it is one. – User Sep 19 '12 at 08:33
  • I don't think it is a bug. As an Englishman, I'd always write €1, but anyone across the channel (in France) would probably expect 1 €. – Michael Sep 19 '12 at 08:36
  • Ok. Then I let it like it's now. Thanks for your answer. – User Sep 19 '12 at 08:47