Java .getAvailableCalendarTypes()
Published Aug 21, 2023
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:gregorybuddhistjapanese
Learn Java on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
- Beginner Friendly.17 hours