java.util.Calendar getGreatestMinimum(int field)

Description :

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

Method Syntax :

public abstract int getLeastMaximum(int field)

Parameter Input :

 

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

 

Method Returns :

This method returns int which corresponds to the lowest maximum 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 getLeastMaximum(int field) method of Calendar class. This example java code simply prints the least maximum values for some of the Calendar fields.

package com.javatutorialhq.java.examples;

import java.util.Calendar;

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

public class CalendarGetLeastMaximumExample {

	public static void main(String[] args){

		Calendar cal = Calendar.getInstance();
		System.out.println("Time:" + cal.getTime());		
		int leastMaxYear = cal.getLeastMaximum(Calendar.YEAR);
		int leastMaxMonth = cal.getLeastMaximum(Calendar.MONTH);
		int leastMaxWeek = cal.getLeastMaximum(Calendar.WEEK_OF_YEAR);
		int leastMaxDate = cal.getLeastMaximum(Calendar.DATE);
		
		System.out.println("Least MaxmimumYear:"+leastMaxYear);
		System.out.println("Least MaxmimumMonth:"+leastMaxMonth);
		System.out.println("Least MaxmimumWeek of Year:"+leastMaxWeek);
		System.out.println("Least MaxmimumDate:"+leastMaxDate);
		
	}
}

Sample Output :

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

Time:Thu Feb 12 21:27:15 CST 2015
Least MaxmimumYear:292269054
Least MaxmimumMonth:11
Least MaxmimumWeek of Year:50
Least MaxmimumDate:28

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :