|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Locale
@TransactionType(value=NOT_SUPPORTED) public final class Locale
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:
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:Locale(String language) Locale(String language, String country)
http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
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.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
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.
This Java Card class is a subset of the CDC 1.1 Locale class. Some interfaces, methods and/or variables have been pruned, and/or other methods simplified, in an effort to reduce the size of this class and/or eliminate dependencies on unsupported features.
ResourceBundle
Field Summary | |
---|---|
static Locale |
CANADA
Useful constant for country. |
static Locale |
CANADA_FRENCH
Useful constant for country. |
static Locale |
CHINA
Useful constant for country. |
static Locale |
CHINESE
Useful constant for language. |
static Locale |
ENGLISH
Useful constant for language. |
static Locale |
FRANCE
Useful constant for country. |
static Locale |
FRENCH
Useful constant for language. |
static Locale |
GERMAN
Useful constant for language. |
static Locale |
GERMANY
Useful constant for country. |
static Locale |
ITALIAN
Useful constant for language. |
static Locale |
ITALY
Useful constant for country. |
static Locale |
JAPAN
Useful constant for country. |
static Locale |
JAPANESE
Useful constant for language. |
static Locale |
KOREA
Useful constant for country. |
static Locale |
KOREAN
Useful constant for language. |
static Locale |
PRC
Useful constant for country. |
static Locale |
SIMPLIFIED_CHINESE
Useful constant for language. |
static Locale |
TAIWAN
Useful constant for country. |
static Locale |
TRADITIONAL_CHINESE
Useful constant for language. |
static Locale |
UK
Useful constant for country. |
static Locale |
US
Useful constant for country. |
Constructor Summary | |
---|---|
Locale(String language)
Construct a locale from a language code. |
|
Locale(String language,
String country)
Construct a locale from language, country. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Returns true if this Locale is equal to another object. |
String |
getCountry()
Returns the country/region code for this locale, which will either be the empty string or an upercase ISO 3166 2-letter code. |
static Locale |
getDefault()
Gets the current value of the default locale for this instance of the Java Virtual Machine. |
String |
getLanguage()
Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code. |
int |
hashCode()
Override hashCode. |
String |
toString()
Getter for the programmatic name of the entire locale, with the language and country separated by underbars. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Locale ENGLISH
public static final Locale FRENCH
public static final Locale GERMAN
public static final Locale ITALIAN
public static final Locale JAPANESE
public static final Locale KOREAN
public static final Locale CHINESE
public static final Locale SIMPLIFIED_CHINESE
public static final Locale TRADITIONAL_CHINESE
public static final Locale FRANCE
public static final Locale GERMANY
public static final Locale ITALY
public static final Locale JAPAN
public static final Locale KOREA
public static final Locale CHINA
public static final Locale PRC
public static final Locale TAIWAN
public static final Locale UK
public static final Locale US
public static final Locale CANADA
public static final Locale CANADA_FRENCH
Constructor Detail |
---|
public Locale(String language, String country)
language
- lowercase two-letter ISO-639 code.country
- uppercase two-letter ISO-3166 code.
NullPointerException
- thrown if either argument is null.public Locale(String language)
language
- lowercase two-letter ISO-639 code.
NullPointerException
- thrown if argument is null.Method Detail |
---|
public static Locale getDefault()
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
public String getLanguage()
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()) ...
public String getCountry()
public final String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object obj)
equals
in class Object
obj
- the reference object with which to compare.
Boolean.hashCode()
,
Hashtable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |