Java.util.Calendar.setFirstDayOfWeek() Method


Advertisements


Description

The java.util.Calendar.setFirstDayOfWeek(int) method sets the first day of the week.

Declaration

Following is the declaration for java.util.Calendar.setFirstDayOfWeek() method

public void setFirstDayOfWeek(int value)

Parameters

  • value -- The given first day of the week.

Return Value

This method does not return a value.

Exception

  • NA

Example

The following example shows the usage of java.util.calendar.setFirstDayOfWeek() method.

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

Let us compile and run the above program, this will produce the following result:

Current first day of the week:2
Altered first day of the week:4

java_util_calendar.htm

Advertisements