Calendar getGreatestMinimum(int) in Java

getGreatestMinimum(): This method is available in java.util.Calendar class of Java.

Syntax:

int java.util.Calendar.getGreatestMinimum(int field)

This method takes one argument of type int as its parameter. This method returns the highest minimum value for the given calendar field of this Calendar instance.

Parameters: One parameter is required for this method.

field: the calendar field.

Returns: the highest minimum value for the given calendar field.

Exceptions: NA

Approach

Java

import java.util.Calendar;

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

        // create a calendar
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 2);

        int field = 1;
        System.out.println(calendar.getGreatestMinimum(field));
    }
}

Output:

1


No comments:

Post a Comment