Home » Java programming language

Java GregorianCalendar getActualMinimum() Method with Example

GregorianCalendar Class getActualMinimum() method: Here, we are going to learn about the getActualMinimum() method of GregorianCalendar Class with its syntax and example.
Submitted by Preeti Jain, on February 15, 2020

GregorianCalendar Class getActualMinimum() method

  • getActualMinimum() method is available in java.util package.
  • getActualMinimum() method is used to get the actual minimum value that this GregorianCalendar field (fi) can hold.
  • getActualMinimum() method is a non-static method, it is accessible with class object only and if we try to access the method with class name then we will get an error.
  • getActualMinimum() method does not throw an exception at the time of returning minimum value that the given field can hold.

Syntax:

    public int getActualMinimum(int fi);

Parameter(s):

  • int fi – represents the GregorianCalendar field (fi).

Return value:

The return type of this method is int, it returns actual minimum value of the given field (fi).

Example:

// Java program to demonstrate the example 
// of int getActualMinimum(int fi) method of 
// GregorianCalendar

import java.util.*;

public class GetActualMinimumOfGregorianCalendar {
    public static void main(String[] args) {
        // Instantiating a GregorianCalendar object
        GregorianCalendar ca = (GregorianCalendar) GregorianCalendar.getInstance();

        // Display current GregorianCalendar
        System.out.println("ca: " + ca.getTime());

        // By using getActualMinimum() method is to
        // return the minimum value of the given field
        // that can hold
        int year = ca.getActualMinimum(GregorianCalendar.YEAR);
        int month = ca.getActualMinimum(GregorianCalendar.MONTH);
        int day = ca.getActualMinimum(GregorianCalendar.DATE);

        // Display Minimum value of GregorianCalendar Fields
        System.out.println("ca.getActualMinimum(GregorianCalendar.YEAR): " + year);
        System.out.println("ca.getActualMinimum(GregorianCalendar.MONTH): " + month);
        System.out.println("ca.getActualMinimum(GregorianCalendar.DATE): " + day);
    }
}

Output

ca: Sat Feb 15 08:43:25 GMT 2020
ca.getActualMinimum(GregorianCalendar.YEAR): 1
ca.getActualMinimum(GregorianCalendar.MONTH): 0
ca.getActualMinimum(GregorianCalendar.DATE): 1


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.