Java Locale - getISO3Country() Method
The java.util.Locale.getISO3Country() method returns a three-letter abbreviation for this locale's country. If the country matches an ISO 3166-1 alpha-2 code, the corresponding ISO 3166-1 alpha-3 uppercase code is returned. If the locale doesn't specify a country, this will be the empty string.
Syntax
public String getISO3Country() throws MissingResourceException
Parameters
No parameter is required.
Return Value
Returns a three-letter abbreviation of this locale's country.
Exception
Throws MissingResourceException, if the three-letter country abbreviation is not available for this locale.
Example:
In the example below, the java.util.Locale.getISO3Country() method is used to get a three-letter abbreviation of the given locale's country.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a locale Locale loc = new Locale("EN", "US"); //printing the locale System.out.println("loc is: " + loc); //printing the country of the locale System.out.println("Country is: " + loc.getISO3Country()); } }
The output of the above code will be:
loc is: en_US Country is: USA
❮ Java.util - Locale