java.time.YearMonth.isLeapYear() 方法示例



說明

java.time.YearMonth.isLeapYear() 方法根據 ISO 前向曆法系統規則檢查年份是否是閏年。

宣告

以下是 java.time.YearMonth.isLeapYear() 方法的宣告。

public boolean isLeapYear()

返回值

如果年份是閏年,則返回 true,否則返回 false。

示例

以下示例展示了 java.time.YearMonth.isLeapYear() 方法的使用。

package com.tutorialspoint;

import java.time.YearMonth;

public class YearMonthDemo {
   public static void main(String[] args) {
 
      YearMonth date = YearMonth.of(2016,12);
      System.out.println(date.isLeapYear());  
   }
}

讓我們編譯並執行以上程式,將產生以下結果 −

true
廣告