addYear()

Adds or subtracts the specified amount of time to the given Year field, based on the calendar's rules.

Syntax

Calendar addYear(Numeric amount)
  1. amount is the amount of date or time to be added to the Year field.

Usage

For example, add 5 years to the current Year field by calling:
Calendar.fromDate(Date.parseString("08/31/1999","mm/dd/yyyy")).addYear(5).toDate().format("mm/dd/yyyy")
This example populates a Word Box. To achieve the same goal and populate a Date box, call:
Calendar.fromDate(Date.parseString("08/31/1999","mm/dd/yyyy")).addYear(5).toDate()