1.

How Will You Add 10 Years To Current Date Using Local Datetime Api Of Java8?

Answer»

Following CODE adds 10 years to current date USING local datetime api −

//ADD 10 years to the current date
LocalDate today = LocalDate.now();
LocalDate nextDecade = today.plus(1, ChronoUnit.DECADES);
System.out.println("Date after ten year: " + nextDecade);

Following code adds 10 years to current date using local datetime api −

//add 10 years to the current date
LocalDate today = LocalDate.now();
LocalDate nextDecade = today.plus(1, ChronoUnit.DECADES);
System.out.println("Date after ten year: " + nextDecade);



Discussion

No Comment Found