Java.util.Calendar.setFirstDayOfWeek()


描述

该java.util.Calendar.setFirstDayOfWeek(INT)方法设置一周的第一天。

声明

以下是java.util.Calendar.setFirstDayOfWeek()方法的声明

public void setFirstDayOfWeek(int value)

参数

value - 给定的第一天。

返回值

此方法不返回值。

异常

NA

实例

以下示例显示了java.util.calendar.setFirstDayOfWeek()方法的用法。

package com.tutorialspoint;

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