ZonedDateTime plus(long amountToAdd, TemporalUnit unit)
returns a copy
of this date-time with the specified amount added.
plus
has the following syntax.
public ZonedDateTime plus(long amountToAdd, TemporalUnit unit)
The following example shows how to use plus
.
import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; //from w w w .j a v a 2s . c om public class Main { public static void main(String[] args) { ZonedDateTime dateTime = ZonedDateTime.now(); ZonedDateTime n = dateTime.plus(12,ChronoUnit.YEARS); System.out.println(n); } }
The code above generates the following result.