java.util.Calendar.setFirstDayOfWeek(int)方法實例
java.util.Calendar.setFirstDayOfWeek(int) 方法設置一周的第一天。
聲明
以下是java.util.Calendar.setFirstDayOfWeek()方法的聲明
public void setFirstDayOfWeek(int value)
參數
-
value -- 給定的一周的第一天。
返回值
此方法不返回任何值。
異常
-
NA
例子
下麵的示例演示java.util.calendar.setFirstDayOfWeek()方法的用法。
package com.yiibai; 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