LocalTime plus(TemporalAmount amountToAdd) example

Description

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;
/*from   w w w . j  a va2s . 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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset