/**
* @author lautturi.com
* Java example: compute time between two dates in java
*/
import java.util.*;
import java.time.LocalDate;
import java.time.Period;
public class Lautturi {
public static void main(String[] args) {
LocalDate parsed = LocalDate.parse("2018-03-17");
LocalDate current = LocalDate.now();
Period p = Period.between(parsed, current);
String timebetween = p.getYears() + " Years, " + p.getMonths() + " Months, " + p.getDays() + " Days";
System.out.println(timebetween);
}
}
output:
2 Years, 8 Months, 9 Days