Sponsered Links
Categories
Sponsered Links

java.util.Locale class

 

The java.util.Locale class represents a locale. There are three main components of a Locale object:

  1. language,
  2. country, and
  3. variant.

The variant argument is a vendor- or browser-specific code. For example, you use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. If there are two variants, separate them with an underscore, and put the most important one first.

To construct a Locale object, use one of the Locale class's constructors.

public Locale(java.lang.String language)
public Locale(java.lang.String language, java.lang.String country)
public Locale(java.lang.String language, java.lang.String country, 
java.lang.String variant)

To construct a Locale object representing the English language used in Canada.

Locale locale = new Locale ("en""CA");

You can also construct a Locale object by calling its static field:

Locale locale = Locale. CANADA_FRENCH;

The static getDefault method returns the user computer's locale.

Locale locale = Locale.getDefault ();

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved