Home » Java programming language

Java Calendar setMinimalDaysInFirstWeek() Method with Example

Calendar Class setMinimalDaysInFirstWeek() method: Here, we are going to learn about the setMinimalDaysInFirstWeek() method of Calendar Class with its syntax and example.
Submitted by Preeti Jain, on February 02, 2020

Calendar Class setMinimalDaysInFirstWeek() method

  • setMinimalDaysInFirstWeek() method is available in java.util package.
  • setMinimalDaysInFirstWeek() method is used to set a minimum number of days needed in the first week of the year.
  • setMinimalDaysInFirstWeek() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.
  • setMinimalDaysInFirstWeek() method does not throw an exception at the time of the set of minimum days needed in the first week of the year.

Syntax:

    public void setMinimalDaysInFirstWeek(int days);

Parameter(s):

  • int days – represents the numeric value to set the number of days needed in the first week of the year.

Return value:

The return type of this method is void, it returns nothing.

Example:

// Java Program to demonstrate the example of
// void setMinimalDaysInFirstWeek(int days) method 
// of Calendar

import java.util.*;

public class SetMinimalDayInFirstWeek {
    public static void main(String args[]) {
        // Instantiating a Calendar object
        Calendar ca = Calendar.getInstance();

        System.out.println("ca: " + ca.getTime());

        // By using setMinimalDaysInFirstWeek(int) method is to 
        // set the minimum number of days in the first week of
        // Calendar
        ca.setMinimalDaysInFirstWeek(5);

        // By using getMinimalDaysInFirstWeek() method is to
        // return the minimal days required to complete first 
        // week of the calendar
        int min_days = ca.getMinimalDaysInFirstWeek();

        // Display status
        System.out.println("ca.getMinimalDaysInFirstWeek(): " + min_days);
    }
}

Output

ca: Sun Feb 02 08:31:30 GMT 2020
ca.getMinimalDaysInFirstWeek(): 5



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.