Java Utility Library

Java Calendar - getAvailableCalendarTypes() Method



The java.util.Calendar.getAvailableCalendarTypes() method returns an unmodifiable Set containing all calendar types supported by Calendar in the runtime environment.

Syntax

public static Set<String> getAvailableCalendarTypes()

Parameters

No parameter is required.

Return Value

Returns an unmodifiable Set containing all available calendar types.

Exception

NA

Example:

In the example below, the java.util.Calendar.getAvailableCalendarTypes() method returns an unmodifiable Set containing all calendar types supported by Calendar in the runtime environment.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a Calendar object with specified date
    Calendar Cal = new GregorianCalendar(2015, 1, 25);

    //printing the Calendar
    System.out.println("The Calendar is: " + Cal.getTime());

    //printing the Set containing all calendar types 
    //supported by Calendar
    Set<String> MySet = Cal.getAvailableCalendarTypes();
    System.out.println("All supported calendar types are: " + MySet);
  }
}

The output of the above code will be:

The Calendar is: Wed Feb 25 00:00:00 UTC 2015
All supported calendar types are: [gregory, buddhist, japanese]

❮ Java.util - Calendar