Home » 
        Java programming language
    
    Java Calendar getActualMaximum() Method with Example
    
    
    
            
        Calendar Class getActualMaximum() method: Here, we are going to learn about the getActualMaximum() method of Calendar Class with its syntax and example.
        Submitted by Preeti Jain, on January 26, 2020
    
    
    Calendar Class getActualMaximum() method
    
        - getActualMaximum() method is available in java.util package.
- getActualMaximum() method is used to return the maximum value that the given calendar field holds depend on the time of this Calendar.
- getActualMaximum() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.
- getActualMaximum() method does not throw an exception at the time of returning the maximum value of this Calendar field value.
Syntax:
    public int getActualMaximum(int fi);
    Parameter(s):
    
        - int fi – it represents the given calendar field.
Return value:
    The return type of the method is int, it returns the maximum value of the given calendar(fi).
    Example:
// Java Program to demonstrate the example of
// int getActualMaximum() method of Calendar
import java.util.*;
public class GetActualMaximumOfCalendar {
    public static void main(String[] args) {
        // Instantiating a Calendar object
        Calendar ca = Calendar.getInstance();
        // Display current calendar
        System.out.println("ca: " + ca.getTime());
        // By using getActualMaximum() method is to
        // return the maximum value of the given field
        // that can hold
        int year = ca.getActualMaximum(Calendar.YEAR);
        int month = ca.getActualMaximum(Calendar.MONTH);
        int day = ca.getActualMaximum(Calendar.DATE);
        // Display Maximum value of Calendar Fields
        System.out.println("ca.getActualMaximum(Calendar.YEAR): " + year);
        System.out.println("ca.getActualMaximum(Calendar.MONTH): " + month);
        System.out.println("ca.getActualMaximum(Calendar.DATE): " + day);
    }
}
Output
ca: Fri Jan 24 12:55:16 GMT 2020
ca.getActualMaximum(Calendar.YEAR): 292278994
ca.getActualMaximum(Calendar.MONTH): 11
ca.getActualMaximum(Calendar.DATE): 31
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement