Calendar setMinimalDaysInFirstWeek(int) in Java

setMinimalDaysInFirstWeek(int): This method is available in java.util.Calendar class of Java.

Syntax:

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

This method takes one argument of type int as its parameter. This method sets the minimal days required in the first week of the year.

Parameters: One parameter is required for this method.

value: the given minimal days required in the first week of the year.

Returns: NA

Exceptions: NA

Approach

Java

import java.util.Calendar;

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

        // create a calendar
        Calendar calendar = Calendar.getInstance();

        int value = 2;
        calendar.setMinimalDaysInFirstWeek(value);

        System.out.println(calendar);
    }
}

Output:

java.util.GregorianCalendar[time=1642958947890,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=1,minimalDaysInFirstWeek=2,ERA=1,YEAR=2022,MONTH=0,WEEK_OF_YEAR=4,WEEK_OF_MONTH=4,DAY_OF_MONTH=23,DAY_OF_YEAR=23,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=10,HOUR_OF_DAY=22,MINUTE=59,SECOND=7,MILLISECOND=890,ZONE_OFFSET=19800000,DST_OFFSET=0]


No comments:

Post a Comment