Java API Tutorial - Java Locale.setDefault(Locale newLocale)








Syntax

Locale.setDefault(Locale newLocale) has the following syntax.

public static void setDefault(Locale newLocale)

Example

In the following code shows how to use Locale.setDefault(Locale newLocale) method.

/*from  w  w  w. j a  v a  2  s . c om*/

import java.util.Locale;

public class Main {
   public static void main(String[] args) {
      Locale locale1 = new Locale("en", "US", "WIN");

      System.out.println("Locale:" + locale1);

      // set another default locale
      Locale.setDefault(new Locale("fr", "FRANCE", "MAC"));

      Locale locale2 = Locale.getDefault();

      // print the new locale
      System.out.println("Locale::" + locale2);
   }
}

The code above generates the following result.