1.

How Will You Add 1 Year To Current Date Using Local Datetime Api Of Java8?

Answer»

Following code ADDS 1 year to current date USING local datetime api −

//ADD 1 year to the current date
LocalDate today = LocalDate.now();
LocalDate nextYear = today.plus(1, ChronoUnit.YEARS);
System.out.println("NEXT year: " + nextYear);

Following code adds 1 year to current date using local datetime api −

//add 1 year to the current date
LocalDate today = LocalDate.now();
LocalDate nextYear = today.plus(1, ChronoUnit.YEARS);
System.out.println("Next year: " + nextYear);



Discussion

No Comment Found