Java Date Time - Java Calendar .setFirstDayOfWeek (int value)








Syntax

Calendar.setFirstDayOfWeek(int value) has the following syntax.

public void setFirstDayOfWeek(int value)

Example

In the following code shows how to use Calendar.setFirstDayOfWeek(int value) method.

/*from  w w  w.j  av  a  2  s.c  om*/

import java.util.Calendar;

public class Main {

   public static void main(String[] args) {

      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);
   }
}

The code above generates the following result.