Example usage for java.util Locale Locale

List of usage examples for java.util Locale Locale

Introduction

In this page you can find the example usage for java.util Locale Locale.

Prototype

public Locale(String language, String country, String variant) 

Source Link

Document

Construct a locale from language, country and variant.

Usage

From source file:Main.java

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

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

    // get language and print it
    System.out.println("Language:" + locale.getLanguage());
}

From source file:Main.java

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

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

    // get variant and print it
    System.out.println("Language:" + locale.getVariant());
}

From source file:Main.java

public static void main(String[] args) {

    Locale locale = new Locale("en", "US", "WIN");

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

    // get a hash code and print it
    System.out.println("Language:" + locale.hashCode());
}

From source file:Main.java

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

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

    // print ISO3 country name for locale
    System.out.println("Name:" + locale.getISO3Country());

}

From source file:Main.java

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

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

    // print ISO3 language name for locale
    System.out.println("Name:" + locale.getISO3Language());

}

From source file:Main.java

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

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

    // print display variant for locale - based on inLocale
    System.out.println("Variant:" + locale.getDisplayVariant());

}

From source file:Main.java

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

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

    // print display variant for locale - based on inLocale
    System.out.println("Variant:" + locale.getDisplayVariant(new Locale("GERMAN", "GERMANY", "MAC")));

}

From source file:Main.java

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);
}

From source file:Main.java

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

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

    // get ISO countries
    String[] countries = Locale.getISOCountries();

    // print countries
    System.out.println("Countries are:");
    for (int i = 0; i < countries.length; i++) {
        System.out.println(i + ":" + countries[i]);
    }//from  www  .j  a v  a2 s. com
}

From source file:Main.java

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

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

    // get ISO languages
    String[] languages = Locale.getISOLanguages();

    // print countries
    System.out.println("Languages are:");
    for (int i = 0; i < languages.length; i++) {
        System.out.println(i + ":" + languages[i]);
    }/* w ww. ja v  a 2 s. com*/
}