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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。