Listing All Available Locales - Java Internationalization

Java examples for Internationalization:Locale

Description

Listing All Available Locales

Demo Code

import java.util.Locale;

public class Main {
  public static void main(String[] argv) {
    Locale[] locales = Locale.getAvailableLocales();

    for (int i = 0; i < locales.length; i++) {
      // Get the 2-letter language code
      String language = locales[i].getLanguage();

      // Get the 2-letter country code; may be equal to ""
      String country = locales[i].getCountry();

      // Get localized name suitable for display to the user
      String locName = locales[i].getDisplayName();
    }// ww w. java2  s.co m

  }
}

Related Tutorials