java.util.Calendar getCalendarType()方法
java.util.Calendar.getCalendarType() 方法返回一个Set,该Set包含java运行时环境支持的所有可用日历类型的字符串集。它返回日历的日历类型或类名称。
1 语法
public String getCalendarType()
2 参数
无
3 返回值
返回Calendar类型或该日历类型的类名称。
4 示例1
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar getCalendarType()方法的例子
*/
import java.util.Calendar;
public class JavaCalendargetCalendarTypeExample1 {
public static void main(String[] args) {
// creating a calendar named as cal1
Calendar calinstance = Calendar.getInstance();
// Print the calendar type of calinstance instance of calendar class
System.out.println("Type of Calendar is " +
calinstance.getCalendarType());
}
}
输出结果为:
Type of Calendar is Gregory
5 示例2
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar getCalendarType()方法的例子
*/
import java.util.GregorianCalendar;
public class JavaCalendargetCalendarTypeExample2 extends GregorianCalendar{
//extending GregorianClass
public static void main(String[] args) {
// creating an instance of type GregorianCalendar
GregorianCalendar calinstance = (GregorianCalendar) GregorianCalendar.getInstance();
// getting the Calendar type using getCalendarType method.
System.out.println("Type of Calendar is: " +
calinstance.getCalendarType());
}
}
输出结果为:
Type of Calendar is: gregory
热门文章
优秀文章