.setMinimalDaysInFirstWeek()
Anonymous contributor
Published Sep 10, 2023Updated May 15, 2024
Contribute to Docs
The .setMinimalDaysInFirstWeek()
method of the Calendar
class sets the minimal number of days required in the first week of a year based on the amount of days passed as an argument to the method.
Syntax
calendar.setMinimalDaysInFirstWeek(int day)
This method takes only one argument, int day
, which is an integer constant representing the number of days which will be set as the minimal days required in the first week of the year.
Example
In the following example, .setMinimalDaysInFirstWeek()
is used to set the minimal days required in the first week of the year.
import java.util.Calendar;public class calendarSetMinimalDaysInFirstWeekExample {public static void main(String[] args) {// Create a calendar instanceCalendar cal = Calendar.getInstance();// Set the minimal days required in the first weekint day = 2;cal.setMinimalDaysInFirstWeek(day);// Print the minimal number of days required in the first weekint min = cal.getMinimalDaysInFirstWeek();System.out.println("Minimal Days in Week: " + min);}}
The output of the above code will be:
Minimal Days in Week: 2
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly16 hours