GregorianCalendar setFirstDayOfWeek(int) in Java

setFirstDayOfWeek(int): This method is available in java.util.GregorianCalendar class of Java.

Syntax:

void java.util.Calendar.setFirstDayOfWeek(int value)

This method takes one argument of type int as its parameter. This method sets the first day of the week.

Parameters: One parameter is required for this method.

value: the given first day of the week.

Returns: NA

Exceptions: NA

Approach

Java

import java.util.GregorianCalendar;

public class GregorianCalendarsetFirstDayOfWeek {
    public static void main(String[] args) {

        GregorianCalendar cal = new GregorianCalendar();

        int value = 5;
        cal.setFirstDayOfWeek(value);
        System.out.println(cal);
    }
}

Output:

java.util.GregorianCalendar[time=1645156074431,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=7,lastRule=null],firstDayOfWeek=5,minimalDaysInFirstWeek=1,ERA=1,YEAR=2022,MONTH=1,WEEK_OF_YEAR=8,WEEK_OF_MONTH=4,DAY_OF_MONTH=18,DAY_OF_YEAR=49,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=9,HOUR_OF_DAY=9,MINUTE=17,SECOND=54,MILLISECOND=431,ZONE_OFFSET=19800000,DST_OFFSET=0]


No comments:

Post a Comment