java.time.Month.maxLength() 方法示例



描述

java.time.Month.maxLength() 方法獲取當月的最大長度(以天為單位)。

宣告

下面是 java.time.Month.maxLength() 方法的宣告。

public int maxLength()

返回值

這個月以天為單位的最大長度,範圍從 29 到 31。

示例

以下示例展示了 java.time.Month.maxLength() 方法的用法。

package com.tutorialspoint;

import java.time.Month;

public class MonthDemo {
   public static void main(String[] args) {
 
      Month month = Month.FEBRUARY;
      System.out.println(month.maxLength());  
   }
}

讓我們編譯並執行上面的程式,它將產生以下結果:

29
廣告
© . All rights reserved.