withEraAdded
Syntax
$calendar.withEraAdded($value)
Description
Creates a new calendar from the given calendar, increasing the epoch by value
. The addition of the value can affect other values, for example the result of toMillis.
If the new epoch number exceeds the total number of possible epochs (in case of GregorianCalendar there are 2 epochs: BC and AD), then the epoch is set to the highest value. It will not start counting from the beginning as for example in withDayAdded.
Parameter
Name | Type | Description | Mandatory | Default |
---|---|---|---|---|
calendar | Business object | The calendar whose epoch is to be changed. It can be a system or user calendar. | yes | |
value | Number | Value by which the epoch should be increased. | yes |
Return value
Type: Business object
A calendar with the changed value for the epoch.
Examples
dateTime(2012, 8, 14, 7, 55, 24, 13).toUserCalendar().withEraAdded(1).era()
Output: 1
The epoch of the date is already equal to 1 and cannot take a higher value because there are only 2 epochs in the Gregorian calendar. Therefore the epoch remains unchanged.