A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/java/util/gregoriancalendar_getactualmaximum.htm below:

Java GregorianCalendar getActualMaximum() Method

Java GregorianCalendar getActualMaximum() Method Description

The Java GregorianCalendar getActualMaximum(int field) method returns the maximum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods.

Declaration

Following is the declaration for java.util.GregorianCalendar.getActualMaximum() method

public int getActualMaximum(int field)
Parameters

field − the calendar field

Return Value

This method returns the maximum of the given field for the time value of this GregorianCalendar

Exception

NA

Getting Actual Maximum Year from a Current Dated GregorianCalendar Instance Example

The following example shows the usage of Java GregorianCalendar getActualMaximum() method. We're creating a GregorianCalendar instance of current date. We're printing the maximum possible value of Year.

package com.tutorialspoint;

import java.util.GregorianCalendar;

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

      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal.getTime());

      // get actual maximum for YEAR
      System.out.println("Actual Maximum:" + cal.getActualMaximum(GregorianCalendar.YEAR));
   }
}
Output

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

Fri Nov 18 10:39:39 IST 2022
Actual Maximum:292278993
Getting Actual Maximum Month from a Current Dated GregorianCalendar Instance Example

The following example shows the usage of Java GregorianCalendar getActualMaximum() method. We're creating a GregorianCalendar instance of current date. We're printing the maximum possible value of Month.

package com.tutorialspoint;

import java.util.GregorianCalendar;

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

      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal.getTime());

      // get actual maximum for Month
      System.out.println("Actual Maximum:" + cal.getActualMaximum(GregorianCalendar.MONTH));
   }
}
Output

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

Fri Nov 18 10:40:25 IST 2022
Actual Maximum:11
Getting Actual Maximum Day from a Current Dated GregorianCalendar Instance Example

The following example shows the usage of Java GregorianCalendar getActualMaximum() method. We're creating a GregorianCalendar instance of current date. We're printing the maximum possible value of day.

package com.tutorialspoint;

import java.util.GregorianCalendar;

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

      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal.getTime());

      // get actual maximum for Day
      System.out.println("Actual Maximum:" + cal.getActualMaximum(GregorianCalendar.DATE));
   }
}
Output

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

Fri Nov 18 10:41:11 IST 2022
Actual Maximum:30

java_util_gregoriancalendar.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4