Java Date Time - LocalTime plus(TemporalAmount amountToAdd) example








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

Syntax

plus has the following syntax.

public LocalTime plus(TemporalAmount amountToAdd)

Example

The following example shows how to use plus.

import java.time.Duration;
import java.time.LocalTime;
//  ww w  .  j  a va 2s. c  o m
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.plus(Duration.ofHours(1));
    System.out.println(s);
  }
}

The code above generates the following result.