当前位置: 首页>>代码示例>>Java>>正文


Java Instant.isAfter方法代码示例

本文整理汇总了Java中java.time.Instant.isAfter方法的典型用法代码示例。如果您正苦于以下问题:Java Instant.isAfter方法的具体用法?Java Instant.isAfter怎么用?Java Instant.isAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.Instant的用法示例。


在下文中一共展示了Instant.isAfter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getQuotaStatus

import java.time.Instant; //导入方法依赖的package包/类
public QuotaStatus getQuotaStatus(MatchPlayer player, Quota quota, Instant now) {
    Duration interval = quota.interval();

    QuotaStatus status = new QuotaStatus(quota, now);
    status.matchesPlayed = 0;
    status.earliestJoinTime = now;

    // Note that this list is reverse-chrono order
    for(Instant joinTime : player.recentMatchCommitments()) {
        Instant expireTime = joinTime.plus(interval);
        if(expireTime.isAfter(now)) {
            if(++status.matchesPlayed == quota.maximum()) {
                status.earliestJoinTime = expireTime;
            }
        } else {
            break;
        }
    }

    return status;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:22,代码来源:QuotaMatchModule.java

示例2: tryAdvance

import java.time.Instant; //导入方法依赖的package包/类
private void tryAdvance() {
    Instant time = null;
    while (allLines.hasNext()) {
        final String line = allLines.next();
        if (line.startsWith(MODIFIED_HEADER)) {
            time = modifiedToInstant(line);
            hasUserTriples = false;
        } else if (isUserTripleQuad(line)) {
            hasUserTriples = true;
        } else if (line.startsWith(TX_COMMIT) && hasUserTriples && nonNull(time)) {
            if (nonNull(from)) {
                if (time.isAfter(from.truncatedTo(MILLIS))) {
                    buffer = new VersionRange(from, time);
                    from = time;
                }
                return;
            }
            from = time;
        }
    }
    buffer = null;
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:23,代码来源:RDFPatch.java

示例3: updateDateRange

import java.time.Instant; //导入方法依赖的package包/类
private void updateDateRange(final TreeNode exactNode, final Range<Instant> range) {
    final Range<Instant> original = exactNode.getDateRange();
    Instant start = original.getStart();
    Instant finish = original.getFinish();

    if (start.isAfter(range.getStart())) {
        start = range.getStart();
    }
    if (finish.isBefore(range.getFinish())) {
        finish = range.getFinish();
    }

    if (start.compareTo(original.getStart()) != 0 ||
            finish.compareTo(original.getFinish()) != 0) {
        this.nextNodes.remove(new DatedNodeKey(exactNode.getValue(), original));

        exactNode.setDateRange(new Range<Instant>(start, finish));
        this.nextNodes.put(
                new DatedNodeKey(exactNode.getValue(), exactNode.getDateRange()), exactNode);
    }
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:22,代码来源:DatedTreeNode.java

示例4: canRestart

import java.time.Instant; //导入方法依赖的package包/类
private boolean canRestart(int playerCount) {
    // If server is on public DNS, it cannot restart
    if(localServer.dns_enabled()) {
        logger.info("Deferring restart because server is on public DNS");
        return false;
    }

    // If we are still waiting for the server to empty, it cannot restart
    final Instant deadline = localServer.dns_toggled_at().plus(config.emptyTimeout());
    if(playerCount > 0 && deadline.isAfter(Instant.now())) {
        logger.info("Deferring restart until the server empties or until " + deadline + ", whichever is first");
        task.schedule(Task.Parameters.fromInstant(deadline));
        return false;
    }

    // If we have given up waiting for the server to empty, it can restart.
    // However, the kick-limit enforced by RestartManager may still prevent it from restarting.
    return true;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:RestartListener.java

示例5: areInSameTimeFrame

import java.time.Instant; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
    final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
    final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 15);

    final Instant start = localStart.toInstant();
    final Instant startOfNext = localStart.plusMinutes(15).toInstant();

    return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:11,代码来源:M15.java

示例6: renew

import java.time.Instant; //导入方法依赖的package包/类
/**
 * Renew a session 
 *
 * @param sessionId the existing session ID
 * @param tokenString a current valid Fernet token
 * @return a new Fernet token with the updated session state embedded
 */
@PUT
@Path("/api/sessions/{sessionId}/renewal")
public String renew(@PathParam("sessionId") final String sessionId, final String tokenString,
        @Context final HttpServletResponse servletResponse) {
    final Token inputToken = Token.fromString(tokenString);
    final Session session = inputToken.validateAndDecrypt(key, validator);
    if (!Objects.equals(sessionId, session.getSessionId())) {
        throw new BadRequestException("SessionID mismatch.");
    }

    final Instant lastRenewed = Instant.ofEpochSecond(session.getLastRenewalTime());
    if (session.hasLastRenewalTime() && lastRenewed.isAfter(Instant.now().minus(Duration.ofMinutes(1)))) {
        // prevent denial-of-service
        // if token was renewed less than a minute ago, tell the client to back off
        servletResponse.addHeader("Retry-After", "60");
        // Too Many Requests: https://tools.ietf.org/html/rfc6585#section-4
        throw new WebApplicationException("Try again in a minute", 429);
    }

    // The token and session are valid, now update the session
    final Builder builder = Session.newBuilder(session);
    builder.setRenewalCount(session.getRenewalCount() + 1);
    builder.setLastRenewalTime(Instant.now().getEpochSecond());
    final Session updatedSession = builder.build();
    // store the updated session in a new Fernet token
    final Token retval = Token.generate(random, key, updatedSession.toByteArray());
    return retval.serialise();
}
 
开发者ID:l0s,项目名称:fernet-java8,代码行数:36,代码来源:ProtocolBuffersExampleIT.java

示例7: notifyChanged

import java.time.Instant; //导入方法依赖的package包/类
@Override
public synchronized void notifyChanged(Instant now) {
    ConfigWithTimestamps current = configWithTimestamps;
    if (now.isAfter(current.getLastCheck().plus(checkInterval))) {
        optionalLastModified()
                .filter(lastModified -> lastModified.isAfter(current.getLastModified()))
                .map(lastModifiedAfterCurrent -> invalidateCache(lastModifiedAfterCurrent, now))
                .orElseGet(() -> {
                    configWithTimestamps = current.withLastCheck(now);
                    return null;
                });
    }
}
 
开发者ID:arkadius,项目名称:tsc-reload,代码行数:14,代码来源:ReloadableConfig.java

示例8: distantExpiringCredentialsUpdatedInBackground

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void distantExpiringCredentialsUpdatedInBackground() throws InterruptedException {
    callClientWithCredentialsProvider(Instant.now().plusSeconds(90), 2);

    Instant endCheckTime = Instant.now().plus(Duration.ofSeconds(5));
    while (Mockito.mockingDetails(stsClient).getInvocations().size() < 2 && endCheckTime.isAfter(Instant.now())) {
        Thread.sleep(100);
    }

    callClient(verify(stsClient, times(2)), Mockito.any());
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:12,代码来源:StsCredentialsProviderTestBase.java

示例9: TimeInterval

import java.time.Instant; //导入方法依赖的package包/类
public TimeInterval(Instant startTime, Instant endTime) {
    requireNonNull(startTime);
    requireNonNull(endTime);

    if (startTime.isAfter(endTime)) {
        throw new IllegalArgumentException(
                "start time can not be after end time, start = " //$NON-NLS-1$
                        + startTime + ", end = " + endTime); //$NON-NLS-1$
    }

    this.startTime = startTime;
    this.endTime = endTime;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:14,代码来源:IntervalTree.java

示例10: tick

import java.time.Instant; //导入方法依赖的package包/类
@Override
public void tick() {
    final Duration timeout = config.timeout();
    final Duration warning = config.warning();

    Instant now = Instant.now();
    Instant kickTime = now.minus(timeout);
    Instant warnTime = warning == null ? null : now.minus(warning);
    Instant lastWarnTime = warning == null || lastCheck == null ? null : lastCheck.minus(warning);

    // Iterate over a copy, because kicking players while iterating the original
    // OnlinePlayerMapAdapter throws a ConcurrentModificationException
    for(Map.Entry<Player, Instant> entry : lastActivity.entrySetCopy()) {
        Player player = entry.getKey();
        Instant time = entry.getValue();

        if(time.isBefore(kickTime)) {
            playerServerChanger.kickPlayer(player, CommonsTranslations.get().t("afk.kick", player));
        } else if(warnTime != null && time.isAfter(lastWarnTime) && !time.isAfter(warnTime)) {
            player.playSound(player.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
            player.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD + CommonsTranslations.get().t(
                "afk.warn", player,
                ChatColor.AQUA.toString() + ChatColor.BOLD +
                    timeout.minus(warning).getSeconds() +
                    ChatColor.RED + ChatColor.BOLD
            ));
        }
    }

    lastCheck = now;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:InactivePlayerListener.java

示例11: areInSameTimeFrame

import java.time.Instant; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
    final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
    final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 30);

    final Instant start = localStart.toInstant();
    final Instant startOfNext = localStart.plusMinutes(30).toInstant();

    return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:11,代码来源:M30.java

示例12: areInSameTimeFrame

import java.time.Instant; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
    final OffsetDateTime localStart = instant1.atOffset(UTC).withMinute(0).withSecond(0).withNano(0);

    final Instant start = localStart.toInstant();
    final Instant startOfNext = localStart.plusHours(1).toInstant();

    return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:10,代码来源:H1.java

示例13: areInSameTimeFrame

import java.time.Instant; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
    final OffsetDateTime localStart = instant1.atOffset(UTC).withSecond(0).withNano(0);
    final Instant start = localStart.toInstant();
    final Instant startOfNext = localStart.plusMinutes(1).toInstant();
    return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:8,代码来源:M1.java

示例14: areInSameTimeFrame

import java.time.Instant; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {

    final ZonedDateTime britishTime = instant1.atZone(BRITISH_TIME_ZONE);
    final DayOfWeek britishDay = britishTime.getDayOfWeek();

    final ZonedDateTime localBase = britishTime.withHour(0).withMinute(0).withSecond(0).withNano(0);

    final ZonedDateTime start;
    final ZonedDateTime end;

    if (britishDay == SUNDAY) {
        if (britishTime.isBefore(localBase.withHour(22))) {
            start = localBase;
            end = localBase.withHour(22);
        } else {
            start = localBase.withHour(22);
            end = localBase.plusDays(2);
        }
    } else if (britishDay == MONDAY) {
        start = localBase.minusDays(1).withHour(22);
        end = localBase.plusDays(1);
    } else {
        start = localBase;
        end = localBase.plusDays(1);
    }

    return instant2.equals(start.toInstant())
            || (instant2.isAfter(start.toInstant()) && instant2.isBefore(end.toInstant()));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:31,代码来源:D1.java

示例15: isCredentialsNonExpired

import java.time.Instant; //导入方法依赖的package包/类
@Override
public boolean isCredentialsNonExpired() {
    //consider the credentials as expired once the token expiry time has passed
    //remember to keep all times in UTC, and optionally allow an extra amount
    //to accomodate clock drift.

    Instant now = Instant.now();

    //for now, assume issued AND expiry are set, we do control the jwt creation =)
    Instant expiry = Instant.ofEpochSecond(jwt.getClaims().getExpiration());
    Instant issuedAt = Instant.ofEpochSecond(jwt.getClaims().getIssuedAt());

    return now.isAfter(issuedAt) && now.isBefore(expiry);
}
 
开发者ID:WASdev,项目名称:sample.microservices.security.jwt,代码行数:15,代码来源:JwtUserDetails.java


注:本文中的java.time.Instant.isAfter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。