Java Calendar getActualMinimum() Method



Description

The Java Calendar getActualMinimum(int field) method returns the highest minimum value for the given calendar field of this Calendar instance.

Declaration

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

public abstract int getActualMinimum(int field)

Parameters

field − the given calendar field.

Return Value

Returns lowest maximum value of the given calendar field.

Exception

NA

Getting Actual Minimum Year from a Current Dated GregorianCalendar Instance Example

The following example shows the usage of Java Calendar getActualMinimum() method. We're creating an instance of a GregorianCalendar of current date. Then we're getting actual minimum value of Year and printing it.

package com.tutorialspoint;

import java.util.Calendar;
import java.util.GregorianCalendar;

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

      // create a calendar    
      Calendar cal = new GregorianCalendar();

      // print the actual min. for year field
      int result = cal.getActualMinimum(Calendar.YEAR);
      System.out.println("The minimum is: " + result);
   }
}

Output

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

The minimum is: 1

Getting Actual Minimum Month from a Current Dated GregorianCalendar Instance Example

The following example shows the usage of Java Calendar getActualMinimum() method. We're creating an instance of a GregorianCalendar of current date. Then we're getting actual minimum value of Month using getActualMinimum() method and printing it.

package com.tutorialspoint;

import java.util.Calendar;
import java.util.GregorianCalendar;

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

      // create a calendar    
      Calendar cal = new GregorianCalendar();

      // print the actual min. for month field
      int result = cal.getActualMinimum(Calendar.MONTH);
      System.out.println("The minimum is: " + result);
   }
}

Output

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

The minimum is: 0

Getting Actual Minimum Day from a Current Dated GregorianCalendar Instance Example

The following example shows the usage of Java Calendar getActualMinimum() method. We're creating an instance of a GregorianCalendar of current date. Then we're getting actual minimum value of Day using getActualMinimum() method and printing it.

package com.tutorialspoint;

import java.util.Calendar;
import java.util.GregorianCalendar;

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

      // create a calendar    
      Calendar cal = new GregorianCalendar();

      // print the actual min. for day field
      int result = cal.getActualMinimum(Calendar.DATE);
      System.out.println("The minimum is: " + result);
   }
}

Output

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

The minimum is: 1
java_util_calendar.htm
Advertisements