dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Beginner
Oct 24, 2018

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Calculate the Difference Between Two LocalDates

Use LocalDate and ChronoUnit:

LocalDate date1 = LocalDate.of(2018, 8, 10); 
LocalDate date2 = LocalDate.of(2018, 8, 30);

As long as the method between of the ChronoUnit enumerator takes 2 Temporals as parameters so you can pass the LocalDate instances without a problem.

long days = ChronoUnit.DAYS.between(date1, date2); 
System.out.println(days);
OCTAVIA ANGHEL
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date