首页 > 文章列表 > 在Java8中怎么检查闰年

在Java8中怎么检查闰年

java java8
362 2023-04-25

在Java 8中检查闰年

package com.shxt.demo02;  
import java.time.LocalDate;  
public class Demo14 {      
public static void main(String[] args) {          
LocalDate today = LocalDate.now();          
if(today.isLeapYear()){              
System.out.println("This year is Leap year");          
}else {              
System.out.println("2018 is not a Leap year");          
}      
}  
}