Using Java, Is there a quick way to convert an alpha-2 country code (IN or GB) to the alpha-3 equivalent (IND or GBR)?
I can get the alpha-2 codes with:
String[] codes = java.util.Locale.getISOLanguages();
That's not a problem, actually my application reads in the alpha-2 code, but I need to output the alpha-3 equivalent .
Is there a similar way like above to get the alpha-3 codes?
Any suggestions?
This works -
Locale locale = new Locale("en","IN");
System.out.println("Country=" + locale.getISO3Country());
Output:
Country=IND
Yes, simple create a Locale and get if from the locale:
String alpha3Country = new Locale("en", alpha2County).getISO3Country();
BTW: getISOLanguages()
returns language codes (lowercase), getISOCountries()
return country codes (uppercase)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With