java.util.Calendar setMinimalDaysInFirstWeek(int value)

Description :

This java tutorial shows how to use the setMinimalDaysInFirstWeek(int value) method of Calendar class of java.util package. This method sets what the minimal days required in the first week of the year are; For example, if the first week is defined as one that contains the first day of the first month of a year, call this method with value 1. If it must be a full week, use value 7.

Method Syntax :

public void setMinimalDaysInFirstWeek(int value)

Parameter Input :

DataType Parameter Description
int value the given minimal days required in the first week of the year.

Method Returns :

This method returns void.

Compatibility Version :

Requires Java 1.1 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of setMinimalDaysInFirstWeek(int value) method of Calendar class.

package com.javatutorialhq.java.examples;

import java.util.Calendar;

/*
 * This example source code demonstrates the use of  
 * setMinimalDaysInFirstWeek(int value) method of Calendar class
 */

public class CalendarSetMinimalDaysInFirstWeekExample {

	public static void main(String[] args) {

		// instantiate the calendar object
		Calendar cal = Calendar.getInstance();

		// get what is the minimal days required in the first week
		int minDayFirstWeek = cal.getMinimalDaysInFirstWeek();
		System.out.println("Current Minimal first day of week:"
				+ minDayFirstWeek);
		
		//set the minimal days required in the first week
		cal.setMinimalDaysInFirstWeek(3);		
		minDayFirstWeek = cal.getMinimalDaysInFirstWeek();
		System.out.println("New Minimal first day of week:"
				+ minDayFirstWeek);
	}
}

Sample Output :

Running the setMinimalDaysInFirstWeek(int value) method example source code of Calendar class will give you the following output:

Current Minimal first day of week:1
New Minimal first day of week:3

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :