Java Programing laungage

java.util Projects

java.util Project 1

Setting the default Locale

In This program shows that how we can set the default locale. In the given Example described the code, how to get and set the default locale.

Previous Home Next
adplus-dvertising
API of program

Locale.getDefault()

This method is used to return the default locale in installed all locales.

Locale.setDefault()

This method is used to set the locale for the default setting. SetDefault() method takes a locale as a parameter for the method to set it as a default locale.

Example


package r4r;
import java.util.*;
public class defaultlocatetest {
public static void main(String[]args)
{
Locale loc = Locale.getDefault();
  System.out.println(loc.getDisplayName() + loc.getCountry());
  Locale.setDefault(Locale.ENGLISH);
  loc = Locale.getDefault();
  System.out.println("For Default Locale : " + loc.getLanguage());
  }
}

Output


English (United States)US
For Default Locale : en

Previous Home Next