|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Locale
public final class Locale
Locales represent a specific country and culture. Classes which can be passed a Locale object tailor their information for a given locale. For instance, currency number formatting is handled differently for the USA and France.
Locales are made up of a language code, a country code, and an optional set of variant strings. Language codes are represented by ISO 639:1988 w/ additions from ISO 639/RA Newsletter No. 1/1989 and a decision of the Advisory Committee of ISO/TC39 on August 8, 1997.
Country codes are represented by ISO 3166. Variant strings are vendor and browser specific. Standard variant strings include "POSIX" for POSIX, "WIN" for MS-Windows, and "MAC" for Macintosh. When there is more than one variant string, they must be separated by an underscore (U+005F).
The default locale is determined by the values of the system properties user.language, user.region, and user.variant, defaulting to "en". Note that the locale does NOT contain the conversion and formatting capabilities (for that, use ResourceBundle and java.text). Rather, it is an immutable tag object for identifying a given locale, which is referenced by these other classes when they must make locale-dependent decisions.
ResourceBundle
,
java.text.Format
,
java.text.NumberFormat
,
java.text.Collator
Constructor Summary | |
---|---|
Locale(String language)
Creates a new locale for a language. |
|
Locale(String language,
String country)
Creates a new locale for the given language and country. |
|
Locale(String language,
String country,
String variant)
Creates a new locale for the given language and country. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Compares two locales. |
String |
getCountry()
Returns the country code of this locale. |
static Locale |
getDefault()
Returns the default Locale. |
String |
getLanguage()
Returns the language code of this locale. |
String |
getVariant()
Returns the variant code of this locale. |
int |
hashCode()
Return the hash code for this locale. |
String |
toString()
Gets the string representation of the current locale. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Locale(String language, String country, String variant)
language
- lowercase two-letter ISO-639 A2 language codecountry
- uppercase two-letter ISO-3166 A2 contry codevariant
- vendor and browser specific
NullPointerException
- if any argument is nullpublic Locale(String language, String country)
language
- lowercase two-letter ISO-639 A2 language codecountry
- uppercase two-letter ISO-3166 A2 country code
NullPointerException
- if either argument is nullpublic Locale(String language)
language
- lowercase two-letter ISO-639 A2 language code
NullPointerException
- if either argument is nullMethod Detail |
---|
public static Locale getDefault()
public String getLanguage()
public String getCountry()
public String getVariant()
public String toString()
toString
in class Object
#getDisplayName()
public int hashCode()
Locale
s are often
used in hash tables.
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public boolean equals(Object obj)
equals
in class Object
obj
- the other locale
Object.hashCode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |