当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java Calendar getAvailableCalendarTypes()用法及代码示例


java.util.Calendar 类的 getAvailableCalendarTypes() 方法返回一个 Set,其中包含 java Runtime Environment 支持的所有可用日历类型的字符串集。

用法

public static Set<String> getAvailableCalendarTypes()

参数

不接受任何值。

返回

以不可修改的 Set 形式返回所有可用的日历类型

抛出

中断异常

例子1

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

例子2

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

例子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]



相关用法


注:本文由纯净天空筛选整理自 Java Calendar getAvailableCalendarTypes() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。