$calendar.withYear($year)
Creates a new calendar from the given calendar, setting the year to year. Changing the year can also change other values such as the day of the week.
| Name | Type | Description | Mandatory | Default |
|---|---|---|---|---|
| calendar | Business object | The calendar whose year is to be changed. It can be a system or user calendar. | yes | |
| year | Number | Value for the new year to be set for the calendar. | yes |
Type: Business object
A calendar with the changed value for the year.
date(2012, 8, 15).toUserCalendar().withYear(2021).year()
Output: 2021