當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Java Calendar isWeekDateSupported()用法及代碼示例


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 isWeekDateSupported() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。