Opposite of subtracting years from a java date, this example will show how to add years to a date using Calendar.add, java 8 date time api, joda DateTime.plusYears and apache common DateUtils.addYears. A couple of years after Packers won superbowl XLV, the San Francisco 49ers handed the packers a wippin. The examples below represents the dates by adding years to the superbowl date.
Straight up Java
Output
Java 8 Date and Time API
Java 8 LocalDateTime.plusYears will return a copy of the LocalDateTime with the specified number of years added.
Output
Joda Time
Joda DateTime.plusYears will return a copy the DateTime plus the specified number of years.
Output
Apache Commons
Apache commons DateUtils.addYears will adds a number of years to the date returning a new object.