Java API Tutorial - 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 w  w  w  .  ja v a  2s  .c o m*/
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.