Java Locale(String language, String country) Constructor

Syntax

Locale(String language, String country) constructor from Locale has the following syntax.

public Locale(String language,  String country)

Example

In the following code shows how to use Locale.Locale(String language, String country) constructor.


import java.util.Locale;
//from   ww w . ja v  a 2 s .  com
public class Main {

   public static void main(String[] args) {
      Locale locale = new Locale("ENGLISH", "US");

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

      // print display name for locale - based on inLocale
      System.out.println("Name:"
              + locale.getDisplayName(new Locale("GERMAN", "GERMANY")));

   }
}

The code above generates the following result.