Example usage for java.time Duration minusDays

List of usage examples for java.time Duration minusDays

Introduction

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

Prototype

public Duration minusDays(long daysToSubtract) 

Source Link

Document

Returns a copy of this duration with the specified duration in standard 24 hour days 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.minusDays(3);
    System.out.println(duration.getSeconds());

}

From source file:org.jgrades.security.service.UserDetailsServiceImpl.java

private boolean isCredentialsNotExpired(User user) {
    Set<JgRole> userRoles = userMgntService.getUserRoles(user);
    int expirationDaysForRole = getExpirationDays(getRoleWithHighestPriority(userRoles));
    if (expirationDaysForRole != 0) {
        LocalDateTime lastPasswordChangeTime = passwordDataRepository.getPasswordDataWithUser(user.getLogin())
                .getLastChange();/*from   w  ww .j  a v a  2  s .  c o  m*/
        Duration duration = Duration.between(lastPasswordChangeTime, LocalDateTime.now());
        return duration.minusDays(expirationDaysForRole).isNegative();
    } else {
        return true;
    }
}