Java Locale getISO3Country() Example
Locale class getISO3Country() method example. This example shows you how to use getISO3Country() method.
Syntax is : public String 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.
For more country codes visit : http://www.davros.org/misc/iso3166.txt
Here is the code.
/**
* @(#) GetISO3CountryLocale.java
* A class representing use of method getISO3Country() of Locale class
in java.util Package.
* @Version 24-May-2008
* @author Rose India Team
*/
import java.util.*;
class GetISO3CountryLocale {
public static void main( String args[] ){
/* Create object of Locale class using contructor
Locale(String language, String country) */
Locale obj1 = new Locale("ENGLISH","Us");
Locale obj2 = new Locale("fr","FR");
System.out.println("object obj1 of Locale class is : "+obj1);
System.out.println("object obj2 of Locale class is : "+obj2);
// getISO3Country() method call.
String code = obj1.getISO3Country();
System.out.println("Three-letter abbreviation for Object obji: "+code);
code = obj2.getISO3Country();
System.out.println("Three-letter abbreviation for Object obj2: "+code);
}
} |
Output of the program.
object obj1 of Locale class is : english_US
object obj2 of Locale class is : fr_FR
Three-letter abbreviation for Object obji: USA
Three-letter abbreviation for Object obj2: FRA |
|