Advertisement
VADMARK

Calculating years between two dates

Feb 21st, 2020
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.22 KB | None | 0 0
  1. LocalDate birthDate = LocalDate.parse("28.10.1988", DateTimeFormatter.ofPattern("dd.MM.yyyy"));
  2. LocalDate todayDate = LocalDate.now();
  3.  
  4. Period period = Period.between(birthDate, todayDate);
  5. int years = period.getYears();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement