Example usage for java.time Instant plus

List of usage examples for java.time Instant plus

Introduction

In this page you can find the example usage for java.time Instant plus.

Prototype

private Instant plus(long secondsToAdd, long nanosToAdd) 

Source Link

Document

Returns a copy of this instant with the specified duration added.

Usage

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;
}