Calendar getMinimalDaysInFirstWeek() Method in Java with Examples

The getMinimalDaysInFirstWeek() method in Calendar class is used to return the minimal days that is required in the first week of the needed year.

Syntax:

public int getMinimalDaysInFirstWeek()

Parameters: The method does not take any paramters.

Return Value: The method returns the minimal days required in the first week of the following year.

Below programs illustrate the working of getMinimalDaysInFirstWeek() Method of Calendar class:
Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java code to illustrate
// getMinimalDaysInFirstWeek() method
  
import java.util.*;
  
public class Calendar_Demo {
    public static void main(String args[])
    {
  
        // Creating a calendar
        Calendar calndr
            = new GregorianCalendar(2018, 6, 10);
  
        // Getting the required minimal days
        int min_days
            = calndr.getMinimalDaysInFirstWeek();
  
        // Displaying the results
        System.out.println("The Minimal"
                           + " days required: "
                           + min_days);
    }
}

chevron_right


Output:

The Minimal days required: 1

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java code to illustrate
// getMinimalDaysInFirstWeek() method
  
import java.util.*;
  
public class Calendar_Demo {
    public static void main(String args[])
    {
  
        // Creating a calendar
        Calendar calndr = Calendar.getInstance();
  
        // Getting the required minimal days
        int min_days
            = calndr.getMinimalDaysInFirstWeek();
  
        // Displaying the results
        System.out.println("The Minimal"
                           + " days required: "
                           + min_days);
    }
}

chevron_right


Output:

The Minimal days required: 1

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getMinimalDaysInFirstWeek–



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.