Java中的LocalDate lengthOfYear()方法
使用lengthOfYear()Java中LocalDate类中的方法可获取特定LocalDate中的年份长度。此方法不需要任何参数,它以特定的LocalDate返回年份的长度,即a年的365或366。
演示此的程序如下所示-
示例
import java.time.*;
public class Main {
public static void main(String[] args) {
LocalDate ld = LocalDate.parse("2019-02-15");
System.out.println("The LocalDate is: " + ld);
System.out.println("The length of the year is: " + ld.lengthOfYear());
}
}输出结果
The LocalDate is: 2019-02-15 The length of the year is: 365
现在让我们了解上面的程序。
首先显示LocalDate。然后,使用该方法获取lengthOfYear()并显示LocalDate中的年份长度。演示这的代码片段如下-
LocalDate ld = LocalDate.parse("2019-02-15");
System.out.println("The LocalDate is: " + ld);
System.out.println("The length of the year is: " + ld.lengthOfYear());热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短