Java.util.Locale.getISO3Country() Method



Description

The java.util.Locale.getISO3Country() method returns a three-letter abbreviation for this locale's country. If the locale doesn't specify a country, this will be the empty string. Otherwise, this will be an uppercase ISO 3166 3-letter country code.

Declaration

Following is the declaration for java.util.Locale.getISO3Country() method

public String getISO3Country()

Parameters

NA

Return Value

This method does not return a value.

Exception

MissingResourceException − Throws MissingResourceException if the three-letter country abbreviation is not available for this locale.

Example

The following example shows the usage of java.util.Locale.getISO3Country() method.

package com.tutorialspoint;

import java.util.*;

public class LocaleDemo {
   public static void main(String[] args) {

      // create a new locale
      Locale locale = new Locale("ENGLISH", "US", "WIN");

      // print locale
      System.out.println("Locale:" + locale);

      // print ISO3 country name for locale
      System.out.println("Name:" + locale.getISO3Country());
   }
}

Let us compile and run the above program, this will produce the following result −

Locale:english_US_WIN
Name:USA
java_util_locale.htm
Advertisements