Home » Java programming language

Java Calendar getAvailableLocales() Method with Example

Calendar Class getAvailableLocales() method: Here, we are going to learn about the getAvailableLocales() method of Calendar Class with its syntax and example.
Submitted by Preeti Jain, on February 02, 2020

Calendar Class getAvailableLocales() method

  • getAvailableLocales() method is available in java.util package.
  • getAvailableLocales() method is used to return Locale[] (an array of Locale) for which to return localized instances by using getInstance() method of this class.
  • getAvailableLocales() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.
  • getAvailableLocales() method does not throw an exception at the time of returning localized instances.

Syntax:

    public static Locale[] getAvailableLocales();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of this method is Locale[], it returns Locale array for which to return existing localized instances.

Example:

// Java Program to demonstrate the example of
// void Locale[] getAvailableLocales() method of 
// Calendar

import java.util.*;

public class GetAvailableLocales {
    public static void main(String[] args) {
        // Instantiating a Calendar object
        Calendar ca = Calendar.getInstance();

        // Display current calendar
        System.out.println("ca: " + ca.getTime());

        // Creating a Locale object
        Locale[] lo = new Locale[5];

        // By using getAvailableLocales() method is 
        // to get the current locales
        lo = Locale.getAvailableLocales();

        System.out.println("First four locales: ");
        for (int i = 0; i < 5; ++i)
            System.out.println(lo[i]);
    }
}

Output

ca: Sun Feb 02 09:43:58 GMT 2020
First four locales: 

nn
ar_JO
bg
kea





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.