Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 732
نمايش فراداده

Localejava.util

Java 1.1cloneable serializable

The Locale class represents a locale: a political, geographical, or cultural region that typically has a distinct language and distinct customs and conventions for such things as formatting dates, times, and numbers. The Locale class defines a number of constants that represent commonly used locales. Locale also defines a static getdefault( ) method that returns the default Locale object, which represents a locale value inherited from the host system. getAvailableLocales( ) returns the list of all locales supported by the underlying system. If none of these methods for obtaining a Locale object are suitable, you can explicitly create your own Locale object. To do this, you must specify a language code and optionally a country code and variant string. getISOCountries( ) and getISOLanguages( ) return the list of supported country codes and language codes.

The Locale class does not implement any internationalization behavior itself; it merely serves as a locale identifier for those classes that can localize their behavior. Given a Locale object, you can invoke the various getdisplay methods to obtain a description of the locale suitable for display to a user. These methods may themselves take a Locale argument, so the names of languages and countries can be localized as appropriate.

Figure 16-42. java.util.Locale

public final class

Locale implements Cloneable, Serializable { // Public Constructors

1.4 public

Locale (String

language ); public

Locale (String

language , String

country ); public

Locale (String

language , String

country , String

variant ); // Public Constants public static final Locale

CANADA ; public static final Locale

CANADA_FRENCH ; public static final Locale

CHINA ; public static final Locale

CHINESE ; public static final Locale

ENGLISH ; public static final Locale

FRANCE ; public static final Locale

FRENCH ; public static final Locale

GERMAN ; public static final Locale

GERMANY ; public static final Locale

ITALIAN ; public static final Locale

ITALY ; public static final Locale

JAPAN ; public static final Locale

JAPANESE ; public static final Locale

KOREA ; public static final Locale

KOREAN ; public static final Locale

PRC ; public static final Locale

SIMPLIFIED_CHINESE ; public static final Locale

TAIWAN ; public static final Locale

TRADITIONAL_CHINESE ; public static final Locale

UK ; public static final Locale

US ; // Public Class Methods

1.2 public static Locale[ ]

getAvailableLocales ( ); public static Locale

getDefault ( );

1.2 public static String[ ]

getISOCountries ( );

1.2 public static String[ ]

getISOLanguages ( ); public static void

setDefault (Locale

newLocale ); synchronized // Public Instance Methods public String

getCountry ( ); public final String

getDisplayCountry ( ); public String

getDisplayCountry (Locale

inLocale ); public final String

getDisplayLanguage ( ); public String

getDisplayLanguage (Locale

inLocale ); public final String

getDisplayName ( ); public String

getDisplayName (Locale

inLocale ); public final String

getDisplayVariant ( ); public String

getDisplayVariant (Locale

inLocale ); public String

getISO3Country ( ) throws MissingResourceException; public String

getISO3Language ( ) throws MissingResourceException; public String

getLanguage ( ); public String

getVariant ( ); // Public Methods Overriding Object public Object

clone ( ); public boolean

equals (Object

obj ); public int

hashCode ( ); public final String

toString ( ); }

Passed To

Too many methods to list.

Returned By

java.text.BreakIterator.getAvailableLocales( ), java.text.Collator.getAvailableLocales( ), java.text.DateFormat.getAvailableLocales( ), java.text.MessageFormat.getLocale( ), java.text.NumberFormat.getAvailableLocales( ), Calendar.getAvailableLocales( ), java.util.Formatter.locale( ), ResourceBundle.getLocale( ), Scanner.locale( ), javax.security.auth.callback.LanguageCallback.getLocale( )