Example usage for java.time Duration minus

List of usage examples for java.time Duration minus

Introduction

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

Prototype

public Duration minus(long amountToSubtract, TemporalUnit unit) 

Source Link

Document

Returns a copy of this duration with the specified duration subtracted.

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.minus(3, ChronoUnit.DAYS);
    System.out.println(duration.getSeconds());

}

From source file:com.querydsl.webhooks.GithubReviewWindow.java

private static Duration truncateAndAppend(Duration duration, long amount, ChronoUnit unit, String description,
        StringBuilder builder) {/* ww w .j a  v a  2 s .  co  m*/

    if (amount > 0) {
        builder.append(amount).append(' ').append(description).append(' ');
    }
    return duration.minus(amount, unit);
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.security.X509SecurityHandler.java

@Override
public void registerRenewer(X509MaterialParameter parameter) {
    if (!isHopsTLSEnabled()) {
        return;//from   w w  w. ja v  a2  s . co m
    }
    if (!renewalTasks.containsKey(parameter.getApplicationId())) {
        LocalDateTime now = DateUtils.getNow();
        LocalDateTime expirationDate = DateUtils.unixEpoch2LocalDateTime(parameter.getExpiration());

        Duration validityPeriod = Duration.between(now, expirationDate);
        Duration delay = validityPeriod.minus(amountOfTimeToSubstractFromExpiration, renewalUnitOfTime);

        ScheduledFuture renewTask = renewalExecutorService
                .schedule(createCertificateRenewerTask(parameter.getApplicationId(), parameter.appUser,
                        parameter.cryptoMaterialVersion), delay.getSeconds(), TimeUnit.SECONDS);
        renewalTasks.put(parameter.getApplicationId(), renewTask);
    }
}