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



描述

java.time.YearMonth.isLeap() 方法根據 ISO 前儒略日曆系統規則檢查年份是否為閏年。

宣告

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

public static  boolean isLeap(int year)

引數

- 檢查是否為閏年的年。

返回值

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

示例

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

package com.tutorialspoint;

import java.time.YearMonth;

public class YearMonthDemo {
   public static void main(String[] args) {
      System.out.println(YearMonth.isLeap(2016));  
   }
}

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

true
廣告
© . All rights reserved.