Java Date Time - ZonedDateTime plus(TemporalAmount amountToAdd) example








ZonedDateTime plus(TemporalAmount amountToAdd) returns a copy of this date-time with the specified amount added.

Syntax

plus has the following syntax.

public ZonedDateTime plus(TemporalAmount amountToAdd)

Example

The following example shows how to use plus.

import java.time.Period;
import java.time.ZonedDateTime;
/*from   ww  w  .j  a v  a  2  s  . c om*/
public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    ZonedDateTime n = dateTime.plus(Period.ofYears(12));
    System.out.println(n);
  } 
}

The code above generates the following result.