How to get a country's official name from a Java Locale?

1k views Asked by At

In ISO-3166, when it comes to the country, there is a difference between "short name" and "full name".

For example, Denmark (link to iso.org reference : https://www.iso.org/obp/ui/#iso:code:3166:DK). Its country code would be DK and DNK (alpha-2 and alpha-3), its numeric code is 208, its short name is 'Denmark', and its full name is 'the Kingdom of Denmark'.

For my current project, I have all the information I need except full name.

Does anyone know of a way to get that kind of data?

1

There are 1 answers

2
Michael On BEST ANSWER

Java's in-built localization doesn't support official country names.

Here's the entry for Denmark in the localization data

DK=Denmark

You can use a REST API like https://restcountries.eu/, or I found this CSV file which seems to contain what you want. You will need to parse it.