Java Date Time - Duration plusMinutes(long minutesToAdd) example








Duration plusMinutes(long minutesToAdd) returns a copy of this duration with the specified duration in minutes added.

Syntax

plusMinutes has the following syntax.

public Duration plusMinutes(long minutesToAdd)

Example

The following example shows how to use plusMinutes.

import java.time.Duration;
import java.time.LocalTime;
//from   w ww  . j av  a 2s. c  o m
public class Main {
  public static void main(String[] args) {
    Duration duration = Duration.between(LocalTime.MIDNIGHT,LocalTime.NOON);
    System.out.println(duration.getSeconds());
    duration = duration.plusMinutes(4000);
    System.out.println(duration.getSeconds());

  }
}

The code above generates the following result.