Build 1.0_r1(from source)

java.util
Class Locale

java.lang.Object
  extended by java.util.Locale
All Implemented Interfaces:
Serializable, Cloneable

public final class Locale
extends Object
implements Cloneable, Serializable

Locale represents a language/country/variant combination. It is an identifier which dictates particular conventions for the presentation of information. The language codes are two letter lowercase codes as defined by ISO-639. The country codes are three letter uppercase codes as defined by ISO-3166. The variant codes are unspecified.

See Also:
ResourceBundle, Serialized Form

Field Summary
static Locale CANADA
          Locale constant for en_CA.
static Locale CANADA_FRENCH
          Locale constant for fr_CA.
static Locale CHINA
          Locale constant for zh_CN.
static Locale CHINESE
          Locale constant for zh.
static Locale ENGLISH
          Locale constant for en.
static Locale FRANCE
          Locale constant for fr_FR.
static Locale FRENCH
          Locale constant for fr.
static Locale GERMAN
          Locale constant for de.
static Locale GERMANY
          Locale constant for de_DE.
static Locale ITALIAN
          Locale constant for it.
static Locale ITALY
          Locale constant for it_IT.
static Locale JAPAN
          Locale constant for ja_JP.
static Locale JAPANESE
          Locale constant for ja.
static Locale KOREA
          Locale constant for ko_KR.
static Locale KOREAN
          Locale constant for ko.
static Locale PRC
          Locale constant for zh_CN.
static Locale SIMPLIFIED_CHINESE
          Locale constant for zh_CN.
static Locale TAIWAN
          Locale constant for zh_TW.
static Locale TRADITIONAL_CHINESE
          Locale constant for zh_TW.
static Locale UK
          Locale constant for en_GB.
static Locale US
          Locale constant for en_US.
 
Constructor Summary
Locale(String language)
          Constructs a new Locale using the specified language.
Locale(String language, String country)
          Constructs a new Locale using the specified language and country codes.
Locale(String language, String country, String variant)
          Constructs a new Locale using the specified language, country, and variant codes.
 
Method Summary
 Object clone()
          Returns a new Locale with the same language, country and variant codes as this Locale.
 boolean equals(Object object)
          Compares the specified object to this Locale and answer if they are equal.
(package private) static Locale[] find()
           
static Locale[] getAvailableLocales()
          Gets the list of installed Locales.
(package private) static ResourceBundle getBundle(String clName, Locale locale)
           
 String getCountry()
          Gets the country code for this Locale.
static Locale getDefault()
          Gets the default Locale.
 String getDisplayCountry()
          Gets the full country name in the default Locale for the country code of this Locale.
 String getDisplayCountry(Locale locale)
          Gets the full country name in the specified Locale for the country code of this Locale.
 String getDisplayLanguage()
          Gets the full language name in the default Locale for the language code of this Locale.
 String getDisplayLanguage(Locale locale)
          Gets the full language name in the specified Locale for the language code of this Locale.
 String getDisplayName()
          Gets the full language, country, and variant names in the default Locale for the codes of this Locale.
 String getDisplayName(Locale locale)
          Gets the full language, country, and variant names in the specified Locale for the codes of this Locale.
 String getDisplayVariant()
          Gets the full variant name in the default Locale for the variant code of this Locale.
 String getDisplayVariant(Locale locale)
          Gets the full variant name in the specified Locale for the variant code of this Locale.
 String getISO3Country()
          Gets the three letter ISO country code which corresponds to the country code for this Locale.
 String getISO3Language()
          Gets the three letter ISO language code which corresponds to the language code for this Locale.
static String[] getISOCountries()
          Gets the list of two letter ISO country codes which can be used as the country code for a Locale.
static String[] getISOLanguages()
          Gets the list of two letter ISO language codes which can be used as the language code for a Locale.
 String getLanguage()
          Gets the language code for this Locale.
 String getVariant()
          Gets the variant code for this Locale.
 int hashCode()
          Returns an integer hash code for the receiver.
static void setDefault(Locale locale)
          Sets the default Locale to the specified Locale.
 String toString()
          Returns the string representation of this Locale.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CANADA

public static final Locale CANADA
Locale constant for en_CA.


CANADA_FRENCH

public static final Locale CANADA_FRENCH
Locale constant for fr_CA.


CHINA

public static final Locale CHINA
Locale constant for zh_CN.


CHINESE

public static final Locale CHINESE
Locale constant for zh.


ENGLISH

public static final Locale ENGLISH
Locale constant for en.


FRANCE

public static final Locale FRANCE
Locale constant for fr_FR.


FRENCH

public static final Locale FRENCH
Locale constant for fr.


GERMAN

public static final Locale GERMAN
Locale constant for de.


GERMANY

public static final Locale GERMANY
Locale constant for de_DE.


ITALIAN

public static final Locale ITALIAN
Locale constant for it.


ITALY

public static final Locale ITALY
Locale constant for it_IT.


JAPAN

public static final Locale JAPAN
Locale constant for ja_JP.


JAPANESE

public static final Locale JAPANESE
Locale constant for ja.


KOREA

public static final Locale KOREA
Locale constant for ko_KR.


KOREAN

public static final Locale KOREAN
Locale constant for ko.


PRC

public static final Locale PRC
Locale constant for zh_CN.


SIMPLIFIED_CHINESE

public static final Locale SIMPLIFIED_CHINESE
Locale constant for zh_CN.


TAIWAN

public static final Locale TAIWAN
Locale constant for zh_TW.


TRADITIONAL_CHINESE

public static final Locale TRADITIONAL_CHINESE
Locale constant for zh_TW.


UK

public static final Locale UK
Locale constant for en_GB.


US

public static final Locale US
Locale constant for en_US.

Constructor Detail

Locale

public Locale(String language)
Constructs a new Locale using the specified language.

Parameters:
language -

Locale

public Locale(String language,
              String country)
Constructs a new Locale using the specified language and country codes.

Parameters:
language -
country -

Locale

public Locale(String language,
              String country,
              String variant)
Constructs a new Locale using the specified language, country, and variant codes.

Parameters:
language -
country -
variant -
Throws:
NullPointerException - if language, country or variant is null.
Method Detail

clone

public Object clone()
Returns a new Locale with the same language, country and variant codes as this Locale.

Overrides:
clone in class Object
Returns:
a shallow copy of this Locale
See Also:
Cloneable

equals

public boolean equals(Object object)
Compares the specified object to this Locale and answer if they are equal. The object must be an instance of Locale and have the same language, country and variant.

Overrides:
equals in class Object
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this Locale, false otherwise
See Also:
hashCode()

find

static Locale[] find()

getAvailableLocales

public static Locale[] getAvailableLocales()
Gets the list of installed Locales.

Returns:
an array of Locale

getCountry

public String getCountry()
Gets the country code for this Locale.

Returns:
a country code

getDefault

public static Locale getDefault()
Gets the default Locale.

Returns:
the default Locale

getDisplayCountry

public final String getDisplayCountry()
Gets the full country name in the default Locale for the country code of this Locale. If there is no matching country name, the country code is returned.

Returns:
a country name

getDisplayCountry

public String getDisplayCountry(Locale locale)
Gets the full country name in the specified Locale for the country code of this Locale. If there is no matching country name, the country code is returned.

Parameters:
locale - the Locale
Returns:
a country name

getDisplayLanguage

public final String getDisplayLanguage()
Gets the full language name in the default Locale for the language code of this Locale. If there is no matching language name, the language code is returned.

Returns:
a language name

getDisplayLanguage

public String getDisplayLanguage(Locale locale)
Gets the full language name in the specified Locale for the language code of this Locale. If there is no matching language name, the language code is returned.

Parameters:
locale - the Locale
Returns:
a language name

getDisplayName

public final String getDisplayName()
Gets the full language, country, and variant names in the default Locale for the codes of this Locale.

Returns:
a Locale name

getDisplayName

public String getDisplayName(Locale locale)
Gets the full language, country, and variant names in the specified Locale for the codes of this Locale.

Parameters:
locale - the Locale
Returns:
a Locale name

getDisplayVariant

public final String getDisplayVariant()
Gets the full variant name in the default Locale for the variant code of this Locale. If there is no matching variant name, the variant code is returned.

Returns:
a variant name

getDisplayVariant

public String getDisplayVariant(Locale locale)
Gets the full variant name in the specified Locale for the variant code of this Locale. If there is no matching variant name, the variant code is returned.

Parameters:
locale - the Locale
Returns:
a variant name

getISO3Country

public String getISO3Country()
                      throws MissingResourceException
Gets the three letter ISO country code which corresponds to the country code for this Locale.

Returns:
a three letter ISO language code
Throws:
MissingResourceException - when there is no matching three letter ISO country code

getISO3Language

public String getISO3Language()
                       throws MissingResourceException
Gets the three letter ISO language code which corresponds to the language code for this Locale.

Returns:
a three letter ISO language code
Throws:
MissingResourceException - when there is no matching three letter ISO language code

getISOCountries

public static String[] getISOCountries()
Gets the list of two letter ISO country codes which can be used as the country code for a Locale.

Returns:
an array of String

getISOLanguages

public static String[] getISOLanguages()
Gets the list of two letter ISO language codes which can be used as the language code for a Locale.

Returns:
an array of String

getLanguage

public String getLanguage()
Gets the language code for this Locale.

Returns:
a language code

getVariant

public String getVariant()
Gets the variant code for this Locale.

Returns:
a variant code

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

setDefault

public static void setDefault(Locale locale)
Sets the default Locale to the specified Locale.

Parameters:
locale - the new default Locale
Throws:
SecurityException - when there is a security manager which does not allow this operation

toString

public final String toString()
Returns the string representation of this Locale.

Overrides:
toString in class Object
Returns:
the string representation of this Locale

getBundle

static ResourceBundle getBundle(String clName,
                                Locale locale)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature