java.util.Calendar getMinimalDaysInFirstWeek()

Description :

This java tutorial shows how to use the getMinimalDaysInFirstWeek() method of Calendar class of java.util package. This method gets what the minimal days required in the first week of the year are; e.g., if the first week is defined as one that contains the first day of the first month of a year, this method returns 1. If the minimal days required must be a full week, this method returns 7.

Method Syntax :

public int getMinimalDaysInFirstWeek()

Parameter Input :

 

DataType Parameter Description
N/A N/A N/A

 

Method Returns :

This method returns the minimal days required in the first week of the year.

Compatibility Version :

Requires Java 1.1 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of getMinimalDaysInFirstWeek() method of Calendar class.

package com.javatutorialhq.java.examples;

import java.util.Calendar;

/*
 * This example source code demonstrates the use of  
 * getMinimalDaysInFirstWeek() method of Calendar class
 */

public class CalendarGetMinimalDaysInFirstWeekExample {

	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(6);		
		minDayFirstWeek = cal.getMinimalDaysInFirstWeek();
		System.out.println("New Minimal first day of week:"
				+ minDayFirstWeek);
	}
}

Sample Output :

Running the getMinimalDaysInFirstWeek() 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:6

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :