Java Date Time - LocalTime plus(long amountToAdd, TemporalUnit unit) example








LocalTime plus(long amountToAdd, TemporalUnit unit) returns a copy of this time with the specified amount added.

Syntax

plus has the following syntax.

public LocalTime plus(long amountToAdd,  TemporalUnit unit)

Example

The following example shows how to use plus.

import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
//from   w w  w .  j  av  a  2  s  .c om
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.plus(14,ChronoUnit.MINUTES);
    System.out.println(s);
  }
}

The code above generates the following result.