Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## java.util
Class Locale

    java.lang.Object
      java.util.Locale

    @TransactionType(value=NOT_SUPPORTED)
    public final class Locale

extends Object

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)

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.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.

Since:
  JDK 1.1, CDC 1.1, Java Card 3.0
See Also:
  `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

### ENGLISH

    public static final Locale ENGLISH

  Useful constant for language.

### FRENCH

    public static final Locale FRENCH

  Useful constant for language.

### GERMAN

    public static final Locale GERMAN

  Useful constant for language.

### ITALIAN

    public static final Locale ITALIAN

  Useful constant for language.

### JAPANESE

    public static final Locale JAPANESE

  Useful constant for language.

### KOREAN

    public static final Locale KOREAN

  Useful constant for language.

### CHINESE

    public static final Locale CHINESE

  Useful constant for language.

### SIMPLIFIED_CHINESE

    public static final Locale SIMPLIFIED_CHINESE

  Useful constant for language.

### TRADITIONAL_CHINESE

    public static final Locale TRADITIONAL_CHINESE

  Useful constant for language.

### FRANCE

    public static final Locale FRANCE

  Useful constant for country.

### GERMANY

    public static final Locale GERMANY

  Useful constant for country.

### ITALY

    public static final Locale ITALY

  Useful constant for country.

### JAPAN

    public static final Locale JAPAN

  Useful constant for country.

### KOREA

    public static final Locale KOREA

  Useful constant for country.

### CHINA

    public static final Locale CHINA

  Useful constant for country.

### PRC

    public static final Locale PRC

  Useful constant for country.

### TAIWAN

    public static final Locale TAIWAN

  Useful constant for country.

### UK

    public static final Locale UK

  Useful constant for country.

### US

    public static final Locale US

  Useful constant for country.

### CANADA

    public static final Locale CANADA

  Useful constant for country.

### CANADA_FRENCH

    public static final Locale CANADA_FRENCH

  Useful constant for country.

Constructor Detail

### Locale

    public Locale(String language,
                  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` - thrown if either argument is null.

### Locale

    public Locale(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` - thrown if argument is null.
  Since:
    1.4

Method Detail

### getDefault

    public static 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

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

### getLanguage

    public 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())
          ...

### getCountry

    public 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.

### toString

    public final String toString()

  Getter for the programmatic name of the entire locale, with the language and country 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. Examples: "en", "de_DE", "_GB"

  Overrides:
    `toString` in class `Object`
  Returns:
    a string representation of the object.

### hashCode

    public int hashCode()

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

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

### equals

    public boolean equals(Object obj)

  Returns true if this Locale is equal to another object. A Locale is deemed equal to another Locale with identical language and country, and unequal to all other objects.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `obj` - the reference object with which to compare.
  Returns:
    true if this Locale is equal to the specified object.
  See Also:
    `Boolean.hashCode()`, `Hashtable`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.