.getAvailableCalendarTypes()

JayRKyd95's avatar
Published Aug 21, 2023
Contribute to Docs

The .getAvailableCalendarTypes() method is a part of Calendar class. This method is used to get all available calendar types that are in the java.until package. It also returns an unmodified Set. Each calendar type has a different unique way of counting days, months and years. For example, the Japanese calendar would be distinctive from the Gregorian or Hijri calendar.

Syntax

getAvailableCalendarTypes()

Note: The calendar types don’t include aliases, such as “gregorian” for “gregory”

Example

The following example demonstrates the basic use of the method.

import java.util.Calendar;
import java.util.Set;
public class getCalendars {
public static void main(String[] args) throws InterruptedException {
System.out.println(" All available calendar types: ");
Set set = Calendar.getAvailableCalendarTypes();
for(Object s:set){
System.out.println(s);
}
}
}

This code returns the following output:

All available calendar types:
gregory
buddhist
japanese

All contributors

Contribute to Docs

Learn Java on Codecademy