java.util.Calendar getAvailableCalendarTypes()方法
java.util.Calendar.getAvailableCalendarTypes() 方法返回一个Set,该Set包含java运行时环境支持的所有可用日历类型的字符串集。
1 语法
public static Set<String> getAvailableCalendarTypes()
2 参数
无
3 返回值
以不可修改的Set形式返回所有可用的Calendar类型
4 示例1
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar getAvailableCalendarTypes()方法的例子
*/
import java.util.Calendar;
import java.util.Set;
public class CalendargetavailablecalendartypeExample1 {
public static void main(String[] args) {
System.out.println(" All Available Calendar types: ");
//method will return all available calendar types
//returnd calendar types are stored in a set.
Set set = Calendar.getAvailableCalendarTypes();
set.forEach((s) -> {
System.out.println(s);
});
}
}
输出结果为:
All Available Calendar types:
gregory
buddhist
Japanese
5 示例2
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar getAvailableCalendarTypes()方法的例子
*/
import java.util.Calendar;
import java.util.Set;
public class CalendargetavailablecalendartypeExample2 {
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);
}
}
}
输出结果为:
All Available Calendar types:
gregory
buddhist
japanese
6 示例3
import java.util.Calendar;
public class CalendargetavailablecalendartypeExample3 {
public static void main(String[] args) throws InterruptedException {
// here we are directly printing the set which is showing all available calendar type
System.out.println(Calendar.getAvailableCalendarTypes());
}
}
输出结果为:
[gregory, buddhist, japanese]
热门文章
优秀文章