java.util.Calendar setFirstDayOfWeek()方法
java.util.Calendar.setFirstDayOfWeek() 方法设置一周的第一天。
1 语法
public void setFirstDayOfWeek(int value)
2 参数
value:给定的一周的第一天。
3 返回值
无
4 示例1
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar setFirstDayOfWeek()方法的例子
*/
import java.util.*;
public class CalendarDemo {
public static void main(String[] args) {
// create a calendar
Calendar cal = Calendar.getInstance();
// print current first day of the week
int day = cal.getFirstDayOfWeek();
System.out.println("Current first day of the week:" + day);
// set first day of the week as something else
cal.setFirstDayOfWeek(Calendar.WEDNESDAY);
// print altered first day of the week
day = cal.getFirstDayOfWeek();;
System.out.println("Altered first day of the week:" + day);
}
}
输出结果为:
Current first day of the week:2
Altered first day of the week:4
热门文章
优秀文章