Java Date Time - Java GregorianCalendar .getLeastMaximum (int field)








Syntax

GregorianCalendar.getLeastMaximum(int field) has the following syntax.

public int getLeastMaximum(int field)

Example

In the following code shows how to use GregorianCalendar.getLeastMaximum(int field) method.

/*from www .  j  av  a 2s. c  o m*/
import java.util.*;

public class Main {

   public static void main(String[] args) {


      GregorianCalendar cal = 
              (GregorianCalendar) GregorianCalendar.getInstance();


      // get least maximum for day_of_month
      int min = cal.getLeastMaximum(GregorianCalendar.DAY_OF_MONTH);
      System.out.println("Least Maximum:" + min);

      // get least maximum for YEAR
      min = cal.getLeastMaximum(GregorianCalendar.YEAR);
      System.out.println("Least Maximum:" + min);

   }
}

The code above generates the following result.