{}
run-icon
Main.java
// Online Java Compiler // Use this editor to write, compile and run your Java code online import java.time.LocalDate; import java.time.Period; import java.time.temporal.ChronoUnit; class Main { public static void main(String[] args) { LocalDate startLocalDate = LocalDate.of(1975, 5 , 23); LocalDate endLocalDate = LocalDate.now(); Period peroidBetween = Period.between(startLocalDate , endLocalDate); System.out.println(peroidBetween.getYears()+" Years"); System.out.println(peroidBetween.getMonths()+" Months"); System.out.println(peroidBetween.getDays()+" Days"); long totalDays = ChronoUnit.DAYS.between(startLocalDate , endLocalDate); System.out.println("totalDays:"+totalDays+" Days"); } }
Output