Home » Java programming language

Java Calendar getGreatestMinimum() Method with Example

Calendar Class getGreatestMinimum() method: Here, we are going to learn about the getGreatestMinimum() method of Calendar Class with its syntax and example.
Submitted by Preeti Jain, on January 26, 2020

Calendar Class getGreatestMinimum() method

  • getGreatestMinimum() method is available in java.util package.
  • getGreatestMinimum() method is used to get the greatest minimum value of the given calendar field(fi) of this Calendar.
  • getGreatestMinimum() 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.
  • getGreatestMinimum() method does not throw an exception at the time of getting the greatest minimum value of this Calendar.

Syntax:

    public abstract int getGreatestMinimum(int fi);

Parameter(s):

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

Return value:

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

Example:

// Java Program to demonstrate the example of
// int getGreatestMinimum() method of Calendar

import java.util.*;

public class GetGreatestMinimum {
    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 getGreatestMinimum(int fi) method is
        // to return the greatest minimum month value
        int month = ca.getGreatestMinimum(Calendar.MONTH);

        //Display minimum value of the month
        System.out.println("ca.getGreatestMinimum(Calendar.MONTH): " + month);
    }
}

Output

ca: Sun Jan 26 12:24:15 GMT 2020
ca.getGreatestMinimum(Calendar.MONTH): 0


Comments and Discussions!

Load comments ↻





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