java.util
Class Locale

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.Locale
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

public final class Locale
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , Serializable sample code for java.io.Serializable definition code for java.io.Serializable

A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation--the number should be formatted according to the customs/conventions of the user's native country, region, or culture.

Create a Locale object using the constructors in this class:

 Locale(String language)
 Locale(String language, String country)
 Locale(String language, String country, String variant)
 
The language argument is a valid ISO Language Code. These codes are the lower-case, two-letter codes as defined by ISO-639. You can find a full list of these codes at a number of sites, such as:
http://www.loc.gov/standards/iso639-2/englangn.html

The country argument is a valid ISO Country Code. These codes are the upper-case, two-letter codes as defined by ISO-3166. You can find a full list of these codes at a number of sites, such as:
http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html

The variant argument is a vendor or browser-specific code. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are two variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might construct a locale with parameters for language, country and variant as: "es", "ES", "Traditional_WIN".

Because a Locale object is just an identifier for a region, no validity check is performed when you construct a Locale. If you want to see whether particular resources are available for the Locale you construct, you must query those resources. For example, ask the NumberFormat for the locales it supports using its getAvailableLocales method.
Note: When you ask for a resource for a particular locale, you get back the best available match, not necessarily precisely what you asked for. For more information, look at ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle .

The Locale class provides a number of convenient constants that you can use to create Locale objects for commonly used locales. For example, the following creates a Locale object for the United States:

 Locale.US
 

Once you've created a Locale you can query it for information about itself. Use getCountry to get the ISO Country Code and getLanguage to get the ISO Language Code. You can use getDisplayCountry to get the name of the country suitable for displaying to the user. Similarly, you can use getDisplayLanguage to get the name of the language suitable for displaying to the user. Interestingly, the getDisplayXXX methods are themselves locale-sensitive and have two versions: one that uses the default locale and one that uses the locale specified as an argument.

The Java 2 platform provides a number of classes that perform locale-sensitive operations. For example, the NumberFormat class formats numbers, currency, or percentages in a locale-sensitive manner. Classes such as NumberFormat have a number of convenience methods for creating a default object of that type. For example, the NumberFormat class provides these three convenience methods for creating a default NumberFormat object:

 NumberFormat.getInstance()
 NumberFormat.getCurrencyInstance()
 NumberFormat.getPercentInstance()
 
These methods have two variants; one with an explicit locale and one without; the latter using the default locale.
 NumberFormat.getInstance(myLocale)
 NumberFormat.getCurrencyInstance(myLocale)
 NumberFormat.getPercentInstance(myLocale)
 
A Locale is the mechanism for identifying the kind of object (NumberFormat) that you would like to get. The locale is just a mechanism for identifying objects, not a container for the objects themselves.

Since:
1.1
See Also:
ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle , Format sample code for java.text.Format definition code for java.text.Format , NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat , Collator sample code for java.text.Collator definition code for java.text.Collator , Serialized Form

Field Summary
static Locale sample code for java.util.Locale definition code for java.util.Locale CANADA sample code for java.util.Locale.CANADA definition code for java.util.Locale.CANADA
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale CANADA_FRENCH sample code for java.util.Locale.CANADA_FRENCH definition code for java.util.Locale.CANADA_FRENCH
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale CHINA sample code for java.util.Locale.CHINA definition code for java.util.Locale.CHINA
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale CHINESE sample code for java.util.Locale.CHINESE definition code for java.util.Locale.CHINESE
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale ENGLISH sample code for java.util.Locale.ENGLISH definition code for java.util.Locale.ENGLISH
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale FRANCE sample code for java.util.Locale.FRANCE definition code for java.util.Locale.FRANCE
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale FRENCH sample code for java.util.Locale.FRENCH definition code for java.util.Locale.FRENCH
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale GERMAN sample code for java.util.Locale.GERMAN definition code for java.util.Locale.GERMAN
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale GERMANY sample code for java.util.Locale.GERMANY definition code for java.util.Locale.GERMANY
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale ITALIAN sample code for java.util.Locale.ITALIAN definition code for java.util.Locale.ITALIAN
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale ITALY sample code for java.util.Locale.ITALY definition code for java.util.Locale.ITALY
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale JAPAN sample code for java.util.Locale.JAPAN definition code for java.util.Locale.JAPAN
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale JAPANESE sample code for java.util.Locale.JAPANESE definition code for java.util.Locale.JAPANESE
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale KOREA sample code for java.util.Locale.KOREA definition code for java.util.Locale.KOREA
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale KOREAN sample code for java.util.Locale.KOREAN definition code for java.util.Locale.KOREAN
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale PRC sample code for java.util.Locale.PRC definition code for java.util.Locale.PRC
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale SIMPLIFIED_CHINESE sample code for java.util.Locale.SIMPLIFIED_CHINESE definition code for java.util.Locale.SIMPLIFIED_CHINESE
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale TAIWAN sample code for java.util.Locale.TAIWAN definition code for java.util.Locale.TAIWAN
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale TRADITIONAL_CHINESE sample code for java.util.Locale.TRADITIONAL_CHINESE definition code for java.util.Locale.TRADITIONAL_CHINESE
          Useful constant for language.
static Locale sample code for java.util.Locale definition code for java.util.Locale UK sample code for java.util.Locale.UK definition code for java.util.Locale.UK
          Useful constant for country.
static Locale sample code for java.util.Locale definition code for java.util.Locale US sample code for java.util.Locale.US definition code for java.util.Locale.US
          Useful constant for country.
 
Constructor Summary
Locale sample code for java.util.Locale.Locale(java.lang.String) definition code for java.util.Locale.Locale(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  language)
          Construct a locale from a language code.
Locale sample code for java.util.Locale.Locale(java.lang.String, java.lang.String) definition code for java.util.Locale.Locale(java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  language, String sample code for java.lang.String definition code for java.lang.String  country)
          Construct a locale from language, country.
Locale sample code for java.util.Locale.Locale(java.lang.String, java.lang.String, java.lang.String) definition code for java.util.Locale.Locale(java.lang.String, java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  language, String sample code for java.lang.String definition code for java.lang.String  country, String sample code for java.lang.String definition code for java.lang.String  variant)
          Construct a locale from language, country, variant.
 
Method Summary
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for java.util.Locale.clone() definition code for java.util.Locale.clone() ()
          Overrides Cloneable
 boolean equals sample code for java.util.Locale.equals(java.lang.Object) definition code for java.util.Locale.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Returns true if this Locale is equal to another object.
static Locale sample code for java.util.Locale definition code for java.util.Locale [] getAvailableLocales sample code for java.util.Locale.getAvailableLocales() definition code for java.util.Locale.getAvailableLocales() ()
          Returns an array of all installed locales.
 String sample code for java.lang.String definition code for java.lang.String getCountry sample code for java.util.Locale.getCountry() definition code for java.util.Locale.getCountry() ()
          Returns the country/region code for this locale, which will either be the empty string or an uppercase ISO 3166 2-letter code.
static Locale sample code for java.util.Locale definition code for java.util.Locale getDefault sample code for java.util.Locale.getDefault() definition code for java.util.Locale.getDefault() ()
          Gets the current value of the default locale for this instance of the Java Virtual Machine.
 String sample code for java.lang.String definition code for java.lang.String getDisplayCountry sample code for java.util.Locale.getDisplayCountry() definition code for java.util.Locale.getDisplayCountry() ()
          Returns a name for the locale's country that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getDisplayCountry sample code for java.util.Locale.getDisplayCountry(java.util.Locale) definition code for java.util.Locale.getDisplayCountry(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a name for the locale's country that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getDisplayLanguage sample code for java.util.Locale.getDisplayLanguage() definition code for java.util.Locale.getDisplayLanguage() ()
          Returns a name for the locale's language that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getDisplayLanguage sample code for java.util.Locale.getDisplayLanguage(java.util.Locale) definition code for java.util.Locale.getDisplayLanguage(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a name for the locale's language that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getDisplayName sample code for java.util.Locale.getDisplayName() definition code for java.util.Locale.getDisplayName() ()
          Returns a name for the locale that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getDisplayName sample code for java.util.Locale.getDisplayName(java.util.Locale) definition code for java.util.Locale.getDisplayName(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a name for the locale that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getDisplayVariant sample code for java.util.Locale.getDisplayVariant() definition code for java.util.Locale.getDisplayVariant() ()
          Returns a name for the locale's variant code that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getDisplayVariant sample code for java.util.Locale.getDisplayVariant(java.util.Locale) definition code for java.util.Locale.getDisplayVariant(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a name for the locale's variant code that is appropriate for display to the user.
 String sample code for java.lang.String definition code for java.lang.String getISO3Country sample code for java.util.Locale.getISO3Country() definition code for java.util.Locale.getISO3Country() ()
          Returns a three-letter abbreviation for this locale's country.
 String sample code for java.lang.String definition code for java.lang.String getISO3Language sample code for java.util.Locale.getISO3Language() definition code for java.util.Locale.getISO3Language() ()
          Returns a three-letter abbreviation for this locale's language.
static String sample code for java.lang.String definition code for java.lang.String [] getISOCountries sample code for java.util.Locale.getISOCountries() definition code for java.util.Locale.getISOCountries() ()
          Returns a list of all 2-letter country codes defined in ISO 3166.
static String sample code for java.lang.String definition code for java.lang.String [] getISOLanguages sample code for java.util.Locale.getISOLanguages() definition code for java.util.Locale.getISOLanguages() ()
          Returns a list of all 2-letter language codes defined in ISO 639.
 String sample code for java.lang.String definition code for java.lang.String getLanguage sample code for java.util.Locale.getLanguage() definition code for java.util.Locale.getLanguage() ()
          Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.
 String sample code for java.lang.String definition code for java.lang.String getVariant sample code for java.util.Locale.getVariant() definition code for java.util.Locale.getVariant() ()
          Returns the variant code for this locale.
 int hashCode sample code for java.util.Locale.hashCode() definition code for java.util.Locale.hashCode() ()
          Override hashCode.
static void setDefault sample code for java.util.Locale.setDefault(java.util.Locale) definition code for java.util.Locale.setDefault(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  newLocale)
          Sets the default locale for this instance of the Java Virtual Machine.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.util.Locale.toString() definition code for java.util.Locale.toString() ()
          Getter for the programmatic name of the entire locale, with the language, country and variant separated by underbars.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

ENGLISH sample code for java.util.Locale.ENGLISH

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  ENGLISH
Useful constant for language.


FRENCH sample code for java.util.Locale.FRENCH

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  FRENCH
Useful constant for language.


GERMAN sample code for java.util.Locale.GERMAN

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  GERMAN
Useful constant for language.


ITALIAN sample code for java.util.Locale.ITALIAN

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  ITALIAN
Useful constant for language.


JAPANESE sample code for java.util.Locale.JAPANESE

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  JAPANESE
Useful constant for language.


KOREAN sample code for java.util.Locale.KOREAN

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  KOREAN
Useful constant for language.


CHINESE sample code for java.util.Locale.CHINESE

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  CHINESE
Useful constant for language.


SIMPLIFIED_CHINESE sample code for java.util.Locale.SIMPLIFIED_CHINESE

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  SIMPLIFIED_CHINESE
Useful constant for language.


TRADITIONAL_CHINESE sample code for java.util.Locale.TRADITIONAL_CHINESE

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  TRADITIONAL_CHINESE
Useful constant for language.


FRANCE sample code for java.util.Locale.FRANCE

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  FRANCE
Useful constant for country.


GERMANY sample code for java.util.Locale.GERMANY

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  GERMANY
Useful constant for country.


ITALY sample code for java.util.Locale.ITALY

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  ITALY
Useful constant for country.


JAPAN sample code for java.util.Locale.JAPAN

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  JAPAN
Useful constant for country.


KOREA sample code for java.util.Locale.KOREA

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  KOREA
Useful constant for country.


CHINA sample code for java.util.Locale.CHINA

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  CHINA
Useful constant for country.


PRC sample code for java.util.Locale.PRC

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  PRC
Useful constant for country.


TAIWAN sample code for java.util.Locale.TAIWAN

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  TAIWAN
Useful constant for country.


UK sample code for java.util.Locale.UK

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  UK
Useful constant for country.


US sample code for java.util.Locale.US

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  US
Useful constant for country.


CANADA sample code for java.util.Locale.CANADA

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  CANADA
Useful constant for country.


CANADA_FRENCH sample code for java.util.Locale.CANADA_FRENCH

public static final Locale sample code for java.util.Locale definition code for java.util.Locale  CANADA_FRENCH
Useful constant for country.

Constructor Detail

Locale sample code for java.util.Locale(java.lang.String, java.lang.String, java.lang.String) definition code for java.util.Locale(java.lang.String, java.lang.String, java.lang.String)

public Locale(String sample code for java.lang.String definition code for java.lang.String  language,
              String sample code for java.lang.String definition code for java.lang.String  country,
              String sample code for java.lang.String definition code for java.lang.String  variant)
Construct a locale from language, country, variant. NOTE: ISO 639 is not a stable standard; some of the language codes it defines (specifically iw, ji, and in) have changed. This constructor accepts both the old codes (iw, ji, and in) and the new codes (he, yi, and id), but all other API on Locale will return only the OLD codes.

Parameters:
language - lowercase two-letter ISO-639 code.
country - uppercase two-letter ISO-3166 code.
variant - vendor and browser specific code. See class description.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - thrown if any argument is null.

Locale sample code for java.util.Locale(java.lang.String, java.lang.String) definition code for java.util.Locale(java.lang.String, java.lang.String)

public Locale(String sample code for java.lang.String definition code for java.lang.String  language,
              String sample code for java.lang.String definition code for java.lang.String  country)
Construct a locale from language, country. NOTE: ISO 639 is not a stable standard; some of the language codes it defines (specifically iw, ji, and in) have changed. This constructor accepts both the old codes (iw, ji, and in) and the new codes (he, yi, and id), but all other API on Locale will return only the OLD codes.

Parameters:
language - lowercase two-letter ISO-639 code.
country - uppercase two-letter ISO-3166 code.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - thrown if either argument is null.

Locale sample code for java.util.Locale(java.lang.String) definition code for java.util.Locale(java.lang.String)

public Locale(String sample code for java.lang.String definition code for java.lang.String  language)
Construct a locale from a language code. NOTE: ISO 639 is not a stable standard; some of the language codes it defines (specifically iw, ji, and in) have changed. This constructor accepts both the old codes (iw, ji, and in) and the new codes (he, yi, and id), but all other API on Locale will return only the OLD codes.

Parameters:
language - lowercase two-letter ISO-639 code.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - thrown if argument is null.
Since:
1.4
Method Detail

getDefault sample code for java.util.Locale.getDefault() definition code for java.util.Locale.getDefault()

public static Locale sample code for java.util.Locale definition code for java.util.Locale  getDefault()
Gets the current value of the default locale for this instance of the Java Virtual Machine.

The Java Virtual Machine sets the default locale during startup based on the host environment. It is used by many locale-sensitive methods if no locale is explicitly specified. It can be changed using the setDefault sample code for java.util.Locale.setDefault(java.util.Locale) definition code for java.util.Locale.setDefault(java.util.Locale) method.

Returns:
the default locale for this instance of the Java Virtual Machine

setDefault sample code for java.util.Locale.setDefault(java.util.Locale) definition code for java.util.Locale.setDefault(java.util.Locale)

public static void setDefault(Locale sample code for java.util.Locale definition code for java.util.Locale  newLocale)
Sets the default locale for this instance of the Java Virtual Machine. This does not affect the host locale.

If there is a security manager, its checkPermission method is called with a PropertyPermission("user.language", "write") permission before the default locale is changed.

The Java Virtual Machine sets the default locale during startup based on the host environment. It is used by many locale-sensitive methods if no locale is explicitly specified.

Since changing the default locale may affect many different areas of functionality, this method should only be used if the caller is prepared to reinitialize locale-sensitive code running within the same Java Virtual Machine, such as the user interface.

Parameters:
newLocale - the new default locale
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager exists and its checkPermission method doesn't allow the operation.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if newLocale is null
See Also:
SecurityManager.checkPermission(java.security.Permission) sample code for java.lang.SecurityManager.checkPermission(java.security.Permission) definition code for java.lang.SecurityManager.checkPermission(java.security.Permission) , PropertyPermission sample code for java.util.PropertyPermission definition code for java.util.PropertyPermission

getAvailableLocales sample code for java.util.Locale.getAvailableLocales() definition code for java.util.Locale.getAvailableLocales()

public static Locale sample code for java.util.Locale definition code for java.util.Locale [] getAvailableLocales()
Returns an array of all installed locales. The array returned must contain at least a Locale instance equal to Locale.US sample code for java.util.Locale.US definition code for java.util.Locale.US .

Returns:
An array of installed locales.

getISOCountries sample code for java.util.Locale.getISOCountries() definition code for java.util.Locale.getISOCountries()

public static String sample code for java.lang.String definition code for java.lang.String [] getISOCountries()
Returns a list of all 2-letter country codes defined in ISO 3166. Can be used to create Locales.


getISOLanguages sample code for java.util.Locale.getISOLanguages() definition code for java.util.Locale.getISOLanguages()

public static String sample code for java.lang.String definition code for java.lang.String [] getISOLanguages()
Returns a list of all 2-letter language codes defined in ISO 639. Can be used to create Locales. [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. The list this function returns includes both the new and the old codes for the languages whose codes have changed.]


getLanguage sample code for java.util.Locale.getLanguage() definition code for java.util.Locale.getLanguage()

public String sample code for java.lang.String definition code for java.lang.String  getLanguage()
Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.

NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. Locale's constructor recognizes both the new and the old codes for the languages whose codes have changed, but this function always returns the old code. If you want to check for a specific language whose code has changed, don't do

 if (locale.getLanguage().equals("he")
    ...
 
Instead, do
 if (locale.getLanguage().equals(new Locale("he", "", "").getLanguage())
    ...

See Also:
getDisplayLanguage() sample code for java.util.Locale.getDisplayLanguage() definition code for java.util.Locale.getDisplayLanguage()

getCountry sample code for java.util.Locale.getCountry() definition code for java.util.Locale.getCountry()

public String sample code for java.lang.String definition code for java.lang.String  getCountry()
Returns the country/region code for this locale, which will either be the empty string or an uppercase ISO 3166 2-letter code.

See Also:
getDisplayCountry() sample code for java.util.Locale.getDisplayCountry() definition code for java.util.Locale.getDisplayCountry()

getVariant sample code for java.util.Locale.getVariant() definition code for java.util.Locale.getVariant()

public String sample code for java.lang.String definition code for java.lang.String  getVariant()
Returns the variant code for this locale.

See Also:
getDisplayVariant() sample code for java.util.Locale.getDisplayVariant() definition code for java.util.Locale.getDisplayVariant()

toString sample code for java.util.Locale.toString() definition code for java.util.Locale.toString()

public final String sample code for java.lang.String definition code for java.lang.String  toString()
Getter for the programmatic name of the entire locale, with the language, country and variant separated by underbars. Language is always lower case, and country is always upper case. If the language is missing, the string will begin with an underbar. If both the language and country fields are missing, this function will return the empty string, even if the variant field is filled in (you can't have a locale with just a variant-- the variant must accompany a valid language or country code). Examples: "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr__MAC"

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of the object.
See Also:
getDisplayName() sample code for java.util.Locale.getDisplayName() definition code for java.util.Locale.getDisplayName()

getISO3Language sample code for java.util.Locale.getISO3Language() definition code for java.util.Locale.getISO3Language()

public String sample code for java.lang.String definition code for java.lang.String  getISO3Language()
                       throws MissingResourceException sample code for java.util.MissingResourceException definition code for java.util.MissingResourceException 
Returns a three-letter abbreviation for this locale's language. If the locale doesn't specify a language, this will be the empty string. Otherwise, this will be a lowercase ISO 639-2/T language code. The ISO 639-2 language codes can be found on-line at http://www.loc.gov/standards/iso639-2/englangn.html

Throws:
MissingResourceException sample code for java.util.MissingResourceException definition code for java.util.MissingResourceException - Throws MissingResourceException if the three-letter language abbreviation is not available for this locale.

getISO3Country sample code for java.util.Locale.getISO3Country() definition code for java.util.Locale.getISO3Country()

public String sample code for java.lang.String definition code for java.lang.String  getISO3Country()
                      throws MissingResourceException sample code for java.util.MissingResourceException definition code for java.util.MissingResourceException 
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. The ISO 3166-2 country codes can be found on-line at http://www.davros.org/misc/iso3166.txt

Throws:
MissingResourceException sample code for java.util.MissingResourceException definition code for java.util.MissingResourceException - Throws MissingResourceException if the three-letter country abbreviation is not available for this locale.

getDisplayLanguage sample code for java.util.Locale.getDisplayLanguage() definition code for java.util.Locale.getDisplayLanguage()

public final String sample code for java.lang.String definition code for java.lang.String  getDisplayLanguage()
Returns a name for the locale's language that is appropriate for display to the user. If possible, the name returned will be localized for the default locale. For example, if the locale is fr_FR and the default locale is en_US, getDisplayLanguage() will return "French"; if the locale is en_US and the default locale is fr_FR, getDisplayLanguage() will return "anglais". If the name returned cannot be localized for the default locale, (say, we don't have a Japanese name for Croatian), this function falls back on the English name, and uses the ISO code as a last-resort value. If the locale doesn't specify a language, this function returns the empty string.


getDisplayLanguage sample code for java.util.Locale.getDisplayLanguage(java.util.Locale) definition code for java.util.Locale.getDisplayLanguage(java.util.Locale)

public String sample code for java.lang.String definition code for java.lang.String  getDisplayLanguage(Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
Returns a name for the locale's language that is appropriate for display to the user. If possible, the name returned will be localized according to inLocale. For example, if the locale is fr_FR and inLocale is en_US, getDisplayLanguage() will return "French"; if the locale is en_US and inLocale is fr_FR, getDisplayLanguage() will return "anglais". If the name returned cannot be localized according to inLocale, (say, we don't have a Japanese name for Croatian), this function falls back on the default locale, on the English name, and finally on the ISO code as a last-resort value. If the locale doesn't specify a language, this function returns the empty string.


getDisplayCountry sample code for java.util.Locale.getDisplayCountry() definition code for java.util.Locale.getDisplayCountry()

public final String sample code for java.lang.String definition code for java.lang.String  getDisplayCountry()
Returns a name for the locale's country that is appropriate for display to the user. If possible, the name returned will be localized for the default locale. For example, if the locale is fr_FR and the default locale is en_US, getDisplayCountry() will return "France"; if the locale is en_US and the default locale is fr_FR, getDisplayLanguage() will return "Etats-Unis". If the name returned cannot be localized for the default locale, (say, we don't have a Japanese name for Croatia), this function falls back on the English name, and uses the ISO code as a last-resort value. If the locale doesn't specify a country, this function returns the empty string.


getDisplayCountry sample code for java.util.Locale.getDisplayCountry(java.util.Locale) definition code for java.util.Locale.getDisplayCountry(java.util.Locale)

public String sample code for java.lang.String definition code for java.lang.String  getDisplayCountry(Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
Returns a name for the locale's country that is appropriate for display to the user. If possible, the name returned will be localized according to inLocale. For example, if the locale is fr_FR and inLocale is en_US, getDisplayCountry() will return "France"; if the locale is en_US and inLocale is fr_FR, getDisplayLanguage() will return "Etats-Unis". If the name returned cannot be localized according to inLocale. (say, we don't have a Japanese name for Croatia), this function falls back on the default locale, on the English name, and finally on the ISO code as a last-resort value. If the locale doesn't specify a country, this function returns the empty string.


getDisplayVariant sample code for java.util.Locale.getDisplayVariant() definition code for java.util.Locale.getDisplayVariant()

public final String sample code for java.lang.String definition code for java.lang.String  getDisplayVariant()
Returns a name for the locale's variant code that is appropriate for display to the user. If possible, the name will be localized for the default locale. If the locale doesn't specify a variant code, this function returns the empty string.


getDisplayVariant sample code for java.util.Locale.getDisplayVariant(java.util.Locale) definition code for java.util.Locale.getDisplayVariant(java.util.Locale)

public String sample code for java.lang.String definition code for java.lang.String  getDisplayVariant(Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
Returns a name for the locale's variant code that is appropriate for display to the user. If possible, the name will be localized for inLocale. If the locale doesn't specify a variant code, this function returns the empty string.


getDisplayName sample code for java.util.Locale.getDisplayName() definition code for java.util.Locale.getDisplayName()

public final String sample code for java.lang.String definition code for java.lang.String  getDisplayName()
Returns a name for the locale that is appropriate for display to the user. This will be the values returned by getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string. The display name will have one of the following forms:

language (country, variant)

language (country)

language (variant)

country (variant)

language

country

variant

depending on which fields are specified in the locale. If the language, country, and variant fields are all empty, this function returns the empty string.


getDisplayName sample code for java.util.Locale.getDisplayName(java.util.Locale) definition code for java.util.Locale.getDisplayName(java.util.Locale)

public String sample code for java.lang.String definition code for java.lang.String  getDisplayName(Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
Returns a name for the locale that is appropriate for display to the user. This will be the values returned by getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string. The display name will have one of the following forms:

language (country, variant)

language (country)

language (variant)

country (variant)

language

country

variant

depending on which fields are specified in the locale. If the language, country, and variant fields are all empty, this function returns the empty string.


clone sample code for java.util.Locale.clone() definition code for java.util.Locale.clone()

public Object sample code for java.lang.Object definition code for java.lang.Object  clone()
Overrides Cloneable

Overrides:
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a clone of this instance.
See Also:
Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

hashCode sample code for java.util.Locale.hashCode() definition code for java.util.Locale.hashCode()

public int hashCode()
Override hashCode. Since Locales are often used in hashtables, caches the value for speed.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

equals sample code for java.util.Locale.equals(java.lang.Object) definition code for java.util.Locale.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Returns true if this Locale is equal to another object. A Locale is deemed equal to another Locale with identical language, country, and variant, and unequal to all other objects.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this Locale is equal to the specified object.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable