Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

Listing all available Locales

This section shows you how to list all the available locales installed with the software development kit.


How to read properties file in Java? Generate random numbers in Java Cloneable Interface in Java What is the flaw with the Stack class? List In Java Java Stack Example HashSet In Java Enumeration in java How to generate random number in java Iterator in java Queue in java Transient Java Keyword clone method in Java Java Queue example Logger in Java Java current date - How to get current date in Java Collection : LinkedList Example Collection : ArrayList Example Random alpha numeric string of fixed size Java List Iterator Example The Hashtable Class The BitSet class Java Vector Java Enumeration Data Structures in Java Java Transient Variable Java Date Format Example Java Properties File Example Map.Entry Java Interface Java Property File java preferences,Change the value of Preferences by user Retrieving a Preference Node Java hasNext Write Keys and Values to the Properties file in Java Get All Keys and Values of the Properties files in Java Properties file in Java Properties file in Java Determining If a Preference Node Contains a Specific Value Change the value of Preferences by user Clone method example in Java Implementing a Simple Event Notifier Determining When a Preference Node Is Added or Removed Listening for Changes to Preference Values in a Preference Node Importing Preferences Finding a Preference in a Preference Tree Retrieving the Parent and Child Nodes of a Preference Node Determining If a Preference Node Exists Removing a Preference Node Creating a Preference Node Getting the Maximum Size of a Preference Key and Value

Listing all available Locales


Locale is the class of java.util.*; package. This class represents the geographical, political and cultural region. Every tasks which requires to perform the operation is called local-sensitive. In this world, each places have it's own country name, language name etc. these can be determined by the object of the Locale class.

This section shows you how to list all the available locales installed with the software development kit. The given program in this section displays all the available language code, country code and full country name. Some following method and APIs which have used in the program for completion the task these are explained as follows:

Above method return a array of available locales which are installed with your software development kit.

Above method returns the two character 'language code' for the specific locale. You can display the full language name by using the getDisplayLanguage() method of the Locale class.

Above method returns the two character country code for the specific locale. If you want to display the full country name then you can use the getDisplayCountry() method of Locale class.

Above method display the full description about the created locale that means the specific geographical or political or the cultural region.

Here is the code of the program:

import java.util.*;

public class Locales{
  public static void main(String[] args){
  Locale[] locales = Locale.getAvailableLocales();
  for(int i = 0; i < locales.length; i++){
  String language = locales[i].getLanguage();
  String country = locales[i].getCountry();
  String locale_name = locales[i].getDisplayName();
  System.out.println(i + ": " + language + ", " + country + ", 
+ locale_name);

Download this example.


Share on Google+Share on Google+

Listing all available Locales

Posted on: April 16, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Listing all available Locales   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
October 7, 2012

I have litle confusion with Locale class in java.util package that is how to operate with Array in this class and for which purpose.... reply soon