3

My Android app from what I've tested works fine with UK and US locales, but when I change the locale to ES I receive the following error:

java.lang.IllegalArgumentException: Unsupported ISO 3166 country: es

I've checked ISO 3166 and es is definitely a valid country code. I've tried changing it to upper case, no difference.

Here's the offending code:

Currency myCurrency;
myCurrency = Currency.getInstance(Locale.getDefault());

Any ideas?

demongolem
  • 9,474
  • 36
  • 90
  • 105
KingFu
  • 1,358
  • 5
  • 22
  • 42
  • One thing you could try is `getAvailableLocales()` and try to see if `es` is an installed locale. – PCoder Mar 07 '13 at 18:36

2 Answers2

1

Locale names are formed by a language code (lowercase), and an optional country code. You should set the default locale to es-Es. For instance, Locale.US is actually en-US.

Javier
  • 12,100
  • 5
  • 46
  • 57
-1

Try this:

Currency.getInstance(new Locale("es", "ES"));
Dharman
  • 30,962
  • 25
  • 85
  • 135
Hasan El-Hefnawy
  • 1,249
  • 1
  • 14
  • 20