Java.util.Calendar.getMinimum() Method


Description

The java.util.Calendar.getMinimum() method returns the minimum value for the given calendar field.

Declaration

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

public abstract int getMinimum(int field)

Parameters

field − the calendar field.

Return Value

The method returns the minimum value for the field entered.

Exception

NA

Example

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

package com.tutorialspoint;

import java.util.*;

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

      // create a calendar
      Calendar cal = Calendar.getInstance();

      // print the minimum value for years
      int min = cal.getMinimum(Calendar.YEAR);
      System.out.println("Minimum Years: "+ min);
   }
}

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

Minimum Years: 1
java_util_calendar.htm
Advertisements