Example usage for java.time Duration plusSeconds

List of usage examples for java.time Duration plusSeconds

Introduction

In this page you can find the example usage for java.time Duration plusSeconds.

Prototype

public Duration plusSeconds(long secondsToAdd) 

Source Link

Document

Returns a copy of this duration with the specified duration in seconds added.

Usage

From source file:Main.java

public static void main(String[] args) {
    Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON);
    System.out.println(duration.getSeconds());
    duration = duration.plusSeconds(4000);
    System.out.println(duration.getSeconds());

}

From source file:com.vmware.vchs.base.DbaasApi.java

protected long getCycleAsSeconds(String cycle) {
    checkNotNull(cycle);/* w  w  w. j  a  v  a  2 s. com*/
    String[] cycleValues = cycle.split(":");
    int length = cycleValues.length;
    Duration seconds;
    if (length == 4) {
        Duration days = Duration.ofDays(Long.parseLong(cycleValues[length - 4]));
        Duration hours = days.plusHours(Long.parseLong(cycleValues[length - 3]));
        Duration minutes = hours.plusMinutes(Long.parseLong(cycleValues[length - 2]));
        seconds = minutes.plusSeconds(Long.parseLong(cycleValues[length - 1]));
    } else {
        throw new FailException("Invalid cycle value" + cycle);
    }
    return seconds.getSeconds();
}