Java.util.GregorianCalendar.getMinimum() Method



Description

The java.util.GregorianCalendar.getMinimum(int field) method returns the minimum value for the given calendar field of this GregorianCalendar instance. The minimum value is defined as the smallest value returned by the get method for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods.

Declaration

Following is the declaration for java.util.GregorianCalendar.getMinimum() method

public int getMinimum(int field)

Parameters

field − the calendar field

Return Value

This method returns the minimum value for the given calendar field.

Exception

NA

Example

The following example shows the usage of java.util.GregorianCalendar.getMinimum() method.

package com.tutorialspoint;

import java.util.*;

public class GregorianCalendarDemo {
   public static void main(String[] args) {

      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal.getTime());

      // get minimum for day_of_month
      int min = cal.getMinimum(GregorianCalendar.DAY_OF_MONTH);
      System.out.println("Minimum:" + min);

      // get minimum for YEAR
      min = cal.getMinimum(GregorianCalendar.YEAR);
      System.out.println("Minimum:" + min);
   }
}

Let us compile and run the above program, this will produce the following result −

Fri May 18 12:39:32 EEST 2012
Minimum:1
Minimum:1
java_util_gregoriancalendar.htm
Advertisements