Calendar 類的 isWeekDateSupported() 方法返回布爾值。它檢查此日曆是否支持星期日期。默認值為假。
用法
public boolean isWeekDateSupported()
參數
沒有傳遞參數。
返回
返回布爾值。
拋出
不拋出異常。
例子1
import java.util.Calendar;
public class JavaCalendarisWeekDateSupportedExample1 {
public static void main(String[] args) {
// creating a Calendar Object calobj
Calendar calobj = Calendar.getInstance();
System.out.println(" week date :" + calobj.get(Calendar.DAY_OF_WEEK));
boolean c = calobj.isWeekDateSupported();
System.out.println("Is week date supported:" + c);
System.out.println("after clearing week date:");
calobj.clear();
System.out.println(" week date :" + calobj.get(Calendar.DAY_OF_WEEK));
c = calobj.isWeekDateSupported();
System.out.println("Is week date supported:" + c);
}
}
輸出:
Current Date and Time is Mon Aug 13 21:24:01 PDT 2018 Interpretation is lenient:true NOW Date and Time is Mon Nov 11 21:24:01 PST 1996 Interpretation is lenient:true
例子2
import java.util.Calendar;
public class JavaCalendarisWeekDateSupportedExample2 {
public static void main(String[] args) {
// creating a Calendar Object calobj
Calendar calobj = Calendar.getInstance();
System.out.println(" week date :" + calobj.get(Calendar.DAY_OF_WEEK));
boolean c = calobj.isWeekDateSupported();
System.out.println("Is week date supported:" + c);
calobj.add(Calendar.DAY_OF_WEEK,8);
System.out.println(" week date :" + calobj.get(Calendar.DAY_OF_WEEK));
c = calobj.isWeekDateSupported();
System.out.println("Is week date supported:" + c);
calobj.set(Calendar.DAY_OF_WEEK,10);
System.out.println(" week date :" + calobj.get(Calendar.DAY_OF_WEEK));
c = calobj.isWeekDateSupported();
System.out.println("Is week date supported:" + c);
}
}
輸出:
week date :2 Is week date supported:true after clearing week date: week date :3 Is week date supported:true week date :3 Is week date supported:true
相關用法
- Java Calendar isLenient()用法及代碼示例
- Java Calendar isSet()用法及代碼示例
- Java Calendar internalGet()用法及代碼示例
- Java Calendar get()用法及代碼示例
- Java Calendar add()用法及代碼示例
- Java Calendar getWeekYear()用法及代碼示例
- Java Calendar computeFields()用法及代碼示例
- Java Calendar after()用法及代碼示例
- Java Calendar setTimeZone()用法及代碼示例
- Java Calendar setFirstDayOfWeek()用法及代碼示例
- Java Calendar setTimeInMillis()用法及代碼示例
- Java Calendar complete()用法及代碼示例
- Java Calendar compareTo()用法及代碼示例
- Java Calendar getDisplayName()用法及代碼示例
- Java Calendar setWeekDate()用法及代碼示例
- Java Calendar getGreatestMinimum()用法及代碼示例
- Java Calendar clear()用法及代碼示例
- Java Calendar roll(int calndr_field, int amt)用法及代碼示例
- Java Calendar setMinimalDaysInFirstWeek()用法及代碼示例
- Java Calendar clear(int cal_field)用法及代碼示例
注:本文由純淨天空篩選整理自 Java Calendar isWeekDateSupported() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。