/** * Subtracts the period of this frequency from the specified date. * * <p>This method implements {@link TemporalAmount}. It is not intended to be called directly. Use * {@link LocalDate#minus(TemporalAmount)} instead. * * @param temporal the temporal object to subtract from * @return the result with this frequency subtracted * @throws DateTimeException if unable to subtract * @throws ArithmeticException if numeric overflow occurs */ @Override public Temporal subtractFrom(Temporal temporal) { // special case for performance if (temporal instanceof LocalDate) { LocalDate date = (LocalDate) temporal; return date.minusMonths(period.toTotalMonths()).minusDays(period.getDays()); } return period.subtractFrom(temporal); }
/** * Persistent Token are used for providing automatic authentication, they should be automatically * deleted after 30 days. * * <p> * * <p>This is scheduled to get fired everyday, at midnight. */ @Scheduled(cron = "0 0 0 * * ?") public void removeOldPersistentTokens() { LocalDate now = LocalDate.now(); persistentTokenRepository .findByTokenDateBefore(now.minusMonths(1)) .stream() .forEach( token -> { log.debug("Deleting token {}", token.getSeries()); User user = token.getUser(); user.getPersistentTokens().remove(token); persistentTokenRepository.delete(token); }); }