Java Date Time - Duration plusDays(long daysToAdd) example








Duration plusDays(long daysToAdd) returns a copy of this duration with the specified duration in standard 24 hour days added.

Syntax

plusDays has the following syntax.

public Duration plusDays(long daysToAdd)

Example

The following example shows how to use plusDays.

import java.time.Duration;
import java.time.LocalTime;
/*ww  w.  ja v  a  2  s. 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.plusDays(4);
    System.out.println(duration.getSeconds());

  }
}

The code above generates the following result.