Related Articles

Related Articles

GregorianCalendar getMinimum() Method in Java
  • Last Updated : 27 Jul, 2018

The java.util.GregorianCalendar.getMinimum() method is an in-built function in Java which returns the minimum value for the particular calendar field passed as parameter to the function. For any possible time value, it is the smallest value that the get() method returns, considering the current values of the getFirstDayOfWeek(), getMinimalDaysInFirstWeek(), getGregorianChange() and getTimeZone() methods as well.

Syntax:

public int getMinimum(int calendarfield)

Parameters: This function accepts one mandatory parameter calendarfield of integer type whose minimum value for this GregorianCalender instance will be returned by the function.

Return Value:
This method returns the minimum value for the specified calendar field for this GregorianCalender instance.

Examples:

Input : DAY_OF_MONTH
Output : 1

Input : WEEK_OF_MONTH
Output : 0

Below programs illustrate the use of java.util.GregorianCalendar.getMinimum() function:



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to illustrate getMinimum() function 
// GregorianCalender
  
import java.io.*;
import java.util.*;
  
class GFG {
     public static void main(String[] args) {
      
      // Create a new calendar
      GregorianCalendar cal = (GregorianCalendar) 
                        GregorianCalendar.getInstance();
  
      // Display the current date and time
      System.out.println("Current Date and Time : "
                                    + cal.getTime());
  
      // Display minimum for WEEK_OF_MONTH
      int minm = cal.getMinimum(GregorianCalendar.WEEK_OF_MONTH);
      System.out.println("Minimum for WEEK_OF_MONTH field :"
                                                   + minm);
  
      // Display minimum for DAY_OF_MONTH
      minm = cal.getMinimum(GregorianCalendar.DAY_OF_MONTH);
      System.out.println("Minimum for DAY_OF_MONTH field:"
                                                  + minm);
   }
}

chevron_right


Output:

Current Date and Time : Fri Jul 27 11:40:24 UTC 2018
Minimum for WEEK_OF_MONTH field :0
Minimum for DAY_OF_MONTH field:1

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to illustrate getMinimum() function 
// GregorianCalender
  
import java.io.*;
import java.util.*;
  
class GFG {
     public static void main(String[] args) {
      
      // Create a new calendar
      GregorianCalendar cal = (GregorianCalendar) 
                        GregorianCalendar.getInstance();
  
      // Display the current date and time
      System.out.println("Current Date and Time : "
                                         + cal.getTime());
  
      // Display minimum for YEAR
      int minm = cal.getMinimum(GregorianCalendar.YEAR);
      System.out.println("Minimum for YEAR field :"
                                          + minm);
  
      // Display minimum for HOUR_OF_DAY
      minm = cal.getMinimum(GregorianCalendar.HOUR_OF_DAY);
      System.out.println("Minimum for HOUR_OF_DAY field :"
                                                  + minm);
   }
}

chevron_right


Output:

Current Date and Time : Fri Jul 27 11:40:28 UTC 2018
Minimum for YEAR field :1
Minimum for HOUR_OF_DAY field :0

Reference:https://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#getMinimum()

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up
Recommended Articles
Page :