Saturday, May 16, 2026
HomeLanguagesJavaCalendar getMinimum() Method in Java with Examples

Calendar getMinimum() Method in Java with Examples

The getMinimum(int calndr_field) method in Calendar class is used to return the Minimum value for the given calendar field(int calndr_field) of this Calendar instance.

Syntax:

public abstract int getMinimum(int calndr_field)

Parameters: The method takes one parameter calndr_field that refers to the calendar field which is to be operated upon.

Return Value: The method returns the Minimum value for the passed calendar field.

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




// Java code to illustrate
// getMinimum() method
  
import java.util.*;
  
public class Calendar_Demo {
    public static void main(String args[])
    {
  
        // Creating a calendar
        Calendar calndr
            = Calendar.getInstance();
  
        // Getting the required months
        System.out.println("Required days: "
                           + calndr.get(
                                 Calendar.DAY_OF_WEEK));
  
        // Getting the Minimum month
        int max_day
            = calndr.getMinimum(
                Calendar.DAY_OF_WEEK);
  
        // Displaying the results
        System.out.println("The Minimum"
                           + " days: "
                           + max_day);
    }
}


Output:

Required days: 3
The Minimum days: 1

Example 2:




// Java code to illustrate
// getMinimum() 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 months
        System.out.println("Required Months: "
                           + calndr.get(
                                 Calendar.MONTH));
  
        // Getting the Minimum month
        int max_month
            = calndr.getMinimum(Calendar.MONTH);
  
        // Displaying the results
        System.out.println("The"
                           + " Minimum months: "
                           + max_month);
    }
}


Output:

Required Months: 6
The Minimum months: 0

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getMinimum-int-

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS