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