Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Oct 28, 2023
Contribute to Docs

In Java, the .getAvailableLocales() method of Calendar class offers an array of locales, representing specific geographical or cultural regions. These locales are crucial for localising date and time representations, ensuring that such information aligns with the conventions and language preferences of various regions and cultures. This functionality acts as a cornerstone for developing applications that serve a broad audience with different language and culture preferences.


The syntax for the .getAvailableLocales() method is as follows:

  • theLocale: The given region to be addressed.
  • The method returns an array of Locale objects, representing available locales.


The following example demonstrates the practical application of the .getAvailableLocales() method. It starts with importing the necessary packages and then proceeds to retrieve the available locales. Finally, it displays the names of these locales.

import java.util.Calendar;
import java.util.Locale;
public class CalendarLocaleExample {
public static void main(String[] args) {
Locale[] availableLocales = Locale.getAvailableLocales();
System.out.println("Available Locales:");
for (Locale locale : availableLocales) {

The code above will return an output similar to the following:

Available Locales:
Arabic (United Arab Emirates)
Arabic (Jordan), Arabic (Syria)
Croatian (Croatia)
French (Belgium)
Spanish (Panama)

All contributors

Looking to contribute?

Learn Java on Codecademy