Home  >  Article  >  Java  >  How to determine whether two dates are equal in Java8

How to determine whether two dates are equal in Java8

WBOY
WBOYforward
2023-05-02 08:46:062213browse

Determine whether two dates are equal in Java 8

package com.shxt.demo02;  
import java.time.LocalDate;  
public class Demo04 {      
public static void main(String[] args) {          
LocalDate date1 = LocalDate.now();          
LocalDate date2 = LocalDate.of(2018,2,5);          
if(date1.equals(date2)){              
System.out.println("时间相等");          
}
else{              
System.out.println("时间不等");          
}      
}  
}

The above is the detailed content of How to determine whether two dates are equal in Java8. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete