Re: [DISCUSS] LANG-1788: ISO3 <-> numeric country code mapping in Commons Lang

Rob Spoor <[email protected]> Sun, 1 Mar 2026 18:06:17 +0100
Newsgroups gmane.comp.jakarta.commons.devel
Message-ID <[email protected]>
I never heard of this before, but it does support getting country names:

Locale.getISOCountries(Locale.IsoCountryCode.PART1_ALPHA2)
         .forEach(code -> System.out.printf("%s: %s%n",
                 code, new Locale("de", code)
                         .getDisplayCountry(Locale.GERMAN)));


It's the last Locale that determines the value you get, the "de" doesn't 
really matter. Replacing Locale.GERMAN with Locale.FRENCH, 
Locale.SPANISH or any other Locale gives different display names.

There is a LocaleNameProvider class that is potentially supported 
through the ServiceLoader mechanism and can provide the name without the 
need to create a Locale, but by default there are no implementations.


On 01/03/2026 16:10, Peter Burka wrote:
> I think this is available in the JDK since 9:
> https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.IsoCountryCode.html#PART1_ALPHA3
> 
> 
> On Sun, Mar 1, 2026, 8:04 AM Elric V <[email protected]> wrote:
> 
>> On 28/02/2026 12:11, Gary Gregory wrote:
>>> I think this is out of scope. A couple of PRs have been discussed and
>>> closed. See GitHub. I'll resolve the ticket.
>> While it may be out of scope for Commons Lang, maybe there's another
>> place for such reference data somewhere? Probably not worth creating a
>> Commons project for just country codes, but maybe there are other
>> similar things?
>>
>>    - Elric
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>