문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

Try this:

Currency.getInstance(new Locale("es", "ES"));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top