日歷類的getActualMaximum()方法 (Calendar Class getActualMaximum() method)
getActualMaximum() method is available in java.util package.
getActualMaximum()方法在java.util包中可用。
getActualMaximum() method is used to return the maximum value that the given calendar field holds depend on the time of this Calendar.
getActualMaximum()方法用于返回給定日歷字段所保留的最大值(取決于此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()方法是一個非靜態方法,可通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。
getActualMaximum() method does not throw an exception at the time of returning the maximum value of this Calendar field value.
返回此Calendar字段值的最大值時, getActualMaximum()方法不會引發異常。
Syntax:
句法:
public int getActualMaximum(int fi);
Parameter(s):
參數:
int fi – it represents the given calendar field.
int fi –代表給定的日歷字段。
Return value:
返回值:
The return type of the method is int, it returns the maximum value of the given calendar(fi).
方法的返回類型為int ,它返回給定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
翻譯自: https://www.includehelp.com/java/calendar-getactualmaximum-method-with-example.aspx