java.util.Calendar getMinimum(int field)

Description :

This java tutorial shows how to use the getMinimum(int field) method of Calendar class of java.util package. This method returns the minimum value for the given calendar field of this Calendar instance. The minimum value is defined as the smallest value returned by the get method for any possible time value.

Method Syntax :

public abstract int getMinimum(int field)

Parameter Input :

 

DataType Parameter Description
int field the calendar field we want to get the minimum value

 

Method Returns :

This method returns int which corresponds to the minimum value for the given calendar field.

Compatibility Version :

Requires Java 1.1 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of getMinimum(int field) method of Calendar class. This example java code simply prints the minimum values for some of the Calendar fields.

package com.javatutorialhq.java.examples;

import java.util.Calendar;

/*
 * This example source code demonstrates the use of  
 * getMinimum(int field) of Calendar class
 */

public class CalendarGetMinimumExample {

	public static void main(String[] args){

		Calendar cal = Calendar.getInstance();
		System.out.println("Time:" + cal.getTime());		
		int minYear = cal.getMinimum(Calendar.YEAR);
		int minMonth = cal.getMinimum(Calendar.MONTH);
		int minWeek = cal.getMinimum(Calendar.WEEK_OF_YEAR);
		int minDate = cal.getMinimum(Calendar.DATE);
		
		System.out.println("Minimum Year:"+minYear);
		System.out.println("Minimum Month:"+minMonth);
		System.out.println("Minimum Week of Year:"+minWeek);
		System.out.println("Minimum Date:"+minDate);
		
	}
}

Sample Output :

Running the getMinimum(int field) method example source code of Calendar class will give you the following output:

Calendar getMinimum(int field) method example

Calendar getMinimum(int field) method example

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :