addMonths method

LocalDateTime addMonths(
  1. int months
)

Returns a new LocalDateTime representing the current value with the given number of months added.

This method does not try to maintain the year of the current value, so adding four months to a value in October will result in a value in the following February.

If the resulting date is invalid, the day of month is reduced to find a valid value. For example, adding one month to January 30th 2011 will return February 28th 2011; subtracting one month from March 30th 2011 will return February 28th 2011.

  • months: The number of months to add

Returns: The current value plus the given number of months.

Implementation

LocalDateTime addMonths(int months) => LocalDateTime.localDateAtTime(calendarDate.addMonths(months), clockTime);