Java Date Time - LocalDateTime plus(TemporalAmount amountToAdd) example








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

Syntax

plus has the following syntax.

public LocalDateTime plus(TemporalAmount amountToAdd)

Example

The following example shows how to use plus.

import java.time.LocalDateTime;
import java.time.Period;
//from ww  w  .  ja  va  2s  .  c o  m
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
    
    LocalDateTime t = a.plus(Period.ofDays(100));
    
    System.out.println(t);
  }
}

The code above generates the following result.