java.util.Calendar 類的 getAvailableCalendarTypes() 方法返回一個 Set,其中包含 java Runtime Environment 支持的所有可用日曆類型的字符串集。它返回日曆類型或日曆類名。
用法
public String getCalendarType()
參數
沒有參數傳遞給這個方法。
返回
返回日曆類型或該日曆類型的類名。
拋出
不拋出任何異常。
例子1
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
例子2
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
相關用法
- Java Calendar get()用法及代碼示例
- Java Calendar getWeekYear()用法及代碼示例
- Java Calendar getDisplayName()用法及代碼示例
- Java Calendar getGreatestMinimum()用法及代碼示例
- Java Calendar getAvailableLocales()用法及代碼示例
- Java Calendar getInstance()用法及代碼示例
- Java Calendar getLeastMaximum()用法及代碼示例
- Java Calendar getTime()用法及代碼示例
- Java Calendar getMinimum()用法及代碼示例
- Java Calendar getActualMaximum()用法及代碼示例
- Java Calendar getAvailableCalendarTypes()用法及代碼示例
- Java Calendar getTimeInMillis()用法及代碼示例
- Java Calendar getMaximum()用法及代碼示例
- Java Calendar getFirstDayOfWeek()用法及代碼示例
- Java Calendar getActualMinimum()用法及代碼示例
- Java Calendar getDisplayNames()用法及代碼示例
- Java Calendar getTimeZone()用法及代碼示例
- Java Calendar getWeeksInWeekYear()用法及代碼示例
- Java Calendar getMinimalDaysInFirstWeek()用法及代碼示例
- Java Calendar add()用法及代碼示例
注:本文由純淨天空篩選整理自 Java Calendar getCalendarType() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。