根据ISO日历系统规则,java.time.YearMonth.isLeap()
方法检查年份是否为闰年。
声明
以下是java.time.YearMonth.isLeap()
方法的声明。
public static boolean isLeap(int year)
参数
year
- 检查是否为闰年。
返回值
如果年份是闰年则返回为true
,否则为false
。
例子
以下示例显示了java.time.YearMonth.isLeapYear()
方法的用法。
package com.yiibai;
import java.time.YearMonth;
public class YearMonthDemo {
public static void main(String[] args) {
System.out.println(YearMonth.isLeap(2016));
}
}
编译并运行上面的程序,这将产生以下结果 -
true