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








Syntax

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

public int getGreatestMinimum(int field)

Example

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

/*from   w  ww.ja  v  a2  s .c  o  m*/

import java.util.*;

public class Main {

   public static void main(String[] args) {

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


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

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

   }
}

The code above generates the following result.