java.time.Month.length() 方法
描述
java.time.Month.length(boolean jumpYear) 方法获取本月的天数。
声明
以下是 java.time.Month.length(boolean leapYear) 方法的声明。
public int length(boolean leapYear)
参数
leapYear − 如果闰年需要长度,则为 true。
返回值
本月的天数,从 28 到 31。
示例
下面的例子展示了 java.time.Month.length(boolean leapYear) 方法的使用。
package com.tutorialspoint;
import java.time.Month;
public class MonthDemo {
public static void main(String[] args) {
Month month = Month.FEBRUARY;
System.out.println(month.length(false));
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
28