The Locale class is instantiated to produce objects that each describe a geographical or cultural region. It is one of several classes that provide you with the ability to write programs that can execute in several different international envirorunents. For example, the formats used to display dates, times, and numbers are different in various regions. Internationalization is a large topic that is beyond the scope of this book. However, most programs will only need to deal with its basics, wJ1ich include setting the current locale. The Locale class defines the following constants that are useful for dealing with the most common locales:

These constructors build a Locale object to represent a specific language and country. These values must contain ISO-standard language and country codes. Auxiliary browser and vendor-specific information can be provided in data. Locale-defines several methods. One of the'most important is setpefault( )shown here: static void setDefault(Locale localeObj) This sets the default locale to that specified by loclilcObj. Some other interesting methods are the following:

final String get Display Country( )
final String get Display Language() ,
final String get Display Name ( )

These return human-readable strings that can be used to display the name of the country, the name'of the language, and the complete .description of the locale. The default locale can be obtained usage get Default( ), shown here:
static Locale get Default( ) Calendar and Gregorian Calendar are examples of classes that operate in a locale sensitive manner. Date,Format and Reformatory, also depend on the locale.

Share This