简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM