Home Java Example Java Util Setting the default Locale

Related Tutorials


 
 

Share on Google+Share on Google+

Setting the default Locale

Advertisement
This section shows you how to set the default locale.

Setting the default Locale

     

This section shows you how to set the default locale. Example presented in the section, illustrates you how to get and set the default locale. 

Following API has been used in the program:

Locale.getDefault():
Above method returns the default locale in installed all locales.

Locale.setDefault():
Above method sets the locale for the default setting. This method takes a locale as a parameter for the method to set it as a default locale.

Here is the code of the program:

import java.util.*;

public class DefaultLocale{
  public static void main(String[] args){
  Locale locale = Locale.getDefault();
  System.out.println(locale.getDisplayName() + locale.getCountry());
  Locale.setDefault(Locale.ENGLISH);
  locale = Locale.getDefault();
  System.out.println("For Default Locale : " + locale.getLanguage());
  }
}

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 16, 2007

Related Tutorials

Discuss: Setting the default Locale   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com