List of usage examples for java.time Instant plus
private Instant plus(long secondsToAdd, long nanosToAdd)
From source file:org.tightblog.service.WeblogEntryManager.java
/** * Determine whether further comments for a particular blog entry are allowed. * @return true if additional comments may be made, false otherwise. */// w w w. j a v a 2 s . c om public boolean canSubmitNewComments(WeblogEntry entry) { if (!entry.isPublished()) { return false; } if (WebloggerProperties.CommentPolicy.NONE .equals(webloggerPropertiesRepository.findOrNull().getCommentPolicy())) { return false; } if (WebloggerProperties.CommentPolicy.NONE.equals(entry.getWeblog().getAllowComments())) { return false; } if (entry.getCommentDays() == 0) { return false; } if (entry.getCommentDays() < 0) { return true; } boolean ret = false; Instant inPubTime = entry.getPubTime(); if (inPubTime != null) { Instant lastCommentDay = inPubTime.plus(entry.getCommentDays(), ChronoUnit.DAYS); if (Instant.now().isBefore(lastCommentDay)) { ret = true; } } return ret; }