The plusWeeks() method of LocalDate class in Java is used to add the number of specified week in this LocalDate and return a copy of LocalDate.For example, 2018-12-24 plus one week would result in 2018-12-31. This instance is immutable and unaffected by this method call.
public LocalDate plusWeeks(long weeksToAdd)
Parameters: This method accepts a single parameter weeksToAdd which represents the weeks to add, may be negative.
Return value: This method returns a LocalDate based on this date with the weeks added, not null.
Exception: This method throws DateTimeException if the result exceeds the supported date range.
Below programs illustrate the plusWeeks() method:
LocalDate before adding weeks: 2018-12-26 LocalDate after adding weeks: 2019-01-30
LocalDate before adding weeks: 2018-12-24 LocalDate after adding weeks: 2018-12-03
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.