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


Java Instant.minus方法代码示例

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


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

示例1: addNodeUpdatesDateRangeStart

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void addNodeUpdatesDateRangeStart() {
    final TreeNode root = createDatedTreeNode("Root", Instant.MIN, Instant.MAX);

    final Instant start = NOW.minus(Period.ofWeeks(5));
    final Instant end = NOW.plus(Period.ofWeeks(5));

    final TreeNode node = createDatedTreeNode("Test1", start, end);
    root.addNode(node);

    final TreeNode other = createDatedTreeNode("Test1", start.minus(Period.ofWeeks(1)), end);
    root.addNode(other);

    final Range<Instant> range = new Range<>(start.minus(Period.ofWeeks(1)), end);
    assertEquals(range, node.getDateRange());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:17,代码来源:DatedTreeNodeTest.java

示例2: testFiveRules

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testFiveRules() {
    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = ruleSetBuilder();
    final Instant now = Instant.now();
    final Instant start = now.minus(Period.ofWeeks(1));
    final Instant finish = now.plus(Period.ofWeeks(4));

    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "*", "*", "INDEX", start, finish, 1L, "1.1");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "S&P", "*", "INDEX", start, finish, 2L, "1.2");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "CME", "ED", "*", "RATE", start, finish, 3L, "1.4");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "*", "*", "US", "*", start, finish, 4L, "1.5");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "*", "*", "US", "*", start, finish, 5L, "1.2");

    final DecisionTreeRuleSet ruleSet = ruleSetBuilder.build();
    final TreeNode node = constructTree(ruleSet);
    Assert.assertNotNull(node);

    checkMatch(inputA, now, node, 3L);
    checkMatch(inputB, now, node, 4L);
    checkMatch(inputC, now, node, 4L);
    checkMatch(inputE, now, node, 5L);

    checkNoMatch(inputD, now, node);
    checkNoMatch(inputF, now, node);
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:26,代码来源:DatedEvaluatorTest.java

示例3: testFourRules

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testFourRules() {
    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = ruleSetBuilder();
    final Instant now = Instant.now();
    final Instant start = now.minus(Period.ofWeeks(1));
    final Instant finish = now.plus(Period.ofWeeks(4));

    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "*", "*", "INDEX", start, finish, 1L, "1.1");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "S&P", "*", "INDEX", start, finish, 2L, "1.2");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "CME", "ED", "*", "RATE", start, finish, 3L, "1.4");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "*", "*", "US", "*", start, finish, 4L, "1.5");

    final DecisionTreeRuleSet ruleSet = ruleSetBuilder.build();
    final TreeNode node = constructTree(ruleSet);
    Assert.assertNotNull(node);

    checkMatch(inputA, now, node, 3L);
    checkMatch(inputB, now, node, 4L);
    checkMatch(inputC, now, node, 4L);

    checkNoMatch(inputD, now, node);
    checkNoMatch(inputE, now, node);
    checkNoMatch(inputF, now, node);
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:25,代码来源:DatedEvaluatorTest.java

示例4: when

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void thatPushNotificationIsSentWhenSingleThresholdWasPassedAndLastNotificationWasSentBeforeDeviceDisconnected() throws Exception {
    Duration threshold = Duration.ofDays(1);
    Instant disconnectInstant = Instant.parse("2010-10-10T10:10:00.00Z");
    Instant lastOfflineNotificationInstant = disconnectInstant.minus(1, ChronoUnit.DAYS);
    Instant jobRunInstant = disconnectInstant.plus(threshold).plusSeconds(1);

    when(pushNotificationService.getLastOfflineNotificationInstant(any(Device.class))).thenReturn(Optional.of(lastOfflineNotificationInstant));

    when(clock.instant()).thenReturn(disconnectInstant);

    offlineDevicesJob.onConfigurationUpdate(Collections.singletonList(threshold));
    offlineDevicesJob.onDeviceDisconnect(new Device(UUID.randomUUID()));

    when(clock.instant()).thenReturn(jobRunInstant);

    offlineDevicesJob.run();

    verify(pushNotificationService, times(1)).sendOfflineNotification(any(Device.class));
}
 
开发者ID:pietvandongen,项目名称:pure-bliss-with-pure-java-functions,代码行数:21,代码来源:OfflineDevicesJobTests.java

示例5: configure

import java.time.Instant; //导入方法依赖的package包/类
@Override
public void configure(JsonElement config, SensorThingsService context, Object edtCtx) {
    getConfigEditor(context, edtCtx).setConfig(config);
    Instant now = Instant.now();
    refTime = now.minus(Days.of(editorDays.getValue()));
    refTime = refTime.minus(Minutes.of(editorMinutes.getValue()));
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:8,代码来源:ValidatorAfter.java

示例6: 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

示例7: calculateHashRate

import java.time.Instant; //导入方法依赖的package包/类
protected BigInteger calculateHashRate(Predicate<BlockHeaderElement> countCondition, Duration period) {
    if (hasBestBlock()) {
        Instant upto = Clock.systemUTC().instant();
        Instant from = upto.minus(period);
        return this.hashRate(getHeaderElement(blockStore.getBestBlock().getHash()), countCondition, b -> checkBlockTimeRange(b, from, upto));
    }
    return BigInteger.ZERO;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:9,代码来源:HashRateCalculator.java

示例8: validationAddsErrorWhenMaximumDurationToNowIsExceeded

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void validationAddsErrorWhenMaximumDurationToNowIsExceeded() {
    Messages messages = messages();
    Instant now = Instant.now();
    DurationNotExceededValidator<Object> validator = new DurationNotExceededValidator<>(DEFAULT_MESSAGE, context -> now.minus(6, MINUTES), Duration.parse("PT5M"));

    Messages returnedMessages = validator.validate(null, messages);
    assertThat(returnedMessages, sameInstance(messages));
    assertThat(returnedMessages.hasErrorLike(DEFAULT_MESSAGE), is(true));
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:11,代码来源:DurationNotExceededValidatorTest.java

示例9: testRangeCheck

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testRangeCheck() {
    final Instant now = Instant.now();
    final Instant start = now.minus(5, ChronoUnit.DAYS);
    final Instant end = now.plus(5, ChronoUnit.DAYS);

    final DateRange dateRange = new DateRange(start, end);
    assertTrue(DateRange.RANGE_CHECK.test(dateRange, now));
    assertTrue(DateRange.RANGE_CHECK.test(dateRange, start));

    // End date is not considered part of the range.
    assertFalse(DateRange.RANGE_CHECK.test(dateRange, end));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-jbl,代码行数:14,代码来源:DateRangeTest.java

示例10: testInstanceCheck

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testInstanceCheck() {
    final Instant now = Instant.now();
    final Instant start = now.minus(5, ChronoUnit.DAYS);
    final Instant end = now.plus(5, ChronoUnit.DAYS);

    final Range<Instant> instantRange = new Range<>(start, end);
    assertTrue(Range.RANGE_CHECK.test(instantRange, now));
    assertTrue(Range.RANGE_CHECK.test(instantRange, start));

    // End date is not considered part of the range.
    assertFalse(Range.RANGE_CHECK.test(instantRange, end));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-jbl,代码行数:14,代码来源:RangeTest.java

示例11: validationAddsErrorWhenMaximumDurationIsExceeded

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void validationAddsErrorWhenMaximumDurationIsExceeded() {
    Messages messages = messages();
    Instant now = Instant.now();
    DurationNotExceededValidator<Object> validator = new DurationNotExceededValidator<>(DEFAULT_MESSAGE, context -> now.minus(6, MINUTES), context -> now, Duration.parse("PT5M"));

    Messages returnedMessages = validator.validate(null, messages);
    assertThat(returnedMessages, sameInstance(messages));
    assertThat(returnedMessages.hasErrorLike(DEFAULT_MESSAGE), is(true));
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:11,代码来源:DurationNotExceededValidatorTest.java

示例12: testAlternativePathsFailurePathsAndValueGroups

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testAlternativePathsFailurePathsAndValueGroups() {
    final Instant now = Instant.now();
    final Instant start = now.minus(Period.ofWeeks(1));
    final Instant finish = now.plus(Period.ofWeeks(4));

    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = RuleSetBuilder.creator(Arrays.asList(
            "MARKUP_CODE", "CLIENT_ACCOUNT", "CLIENT_SPN", "ADVISOR_SPN", "EXECUTION_VENUE", "MEMBERSHIP",
            "SECURITY_TYPE", "CONTRACT", "FEE_GROUP", "PRODUCT_GROUP", "EXCHANGE", "REGION"));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:VG1589CLM:0151488:4679563:7888805", "*", "*", "*", "*", "381", "Equity indices",
                    "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 1L)));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:VG1589CLM:0151488:4679563:7888805", "*", "*", "*", "*", "*", "*", "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 2L)));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:AdVG1589CLM:0151488:3679563:6888805", "*", "*", "*", "*", "*", "*", "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 3L)));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:VG1589CLM:0151488:4679563:7888805", "ELEC", "NMEM", "*", "*", "123", "Equity indices",
                    "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 4L)));

    final DecisionTreeRuleSet ruleSet = ruleSetBuilder.build();
    final TreeNode node = constructTree(ruleSet);
    Assert.assertNotNull(node);

    final List<String> inputs = Arrays.asList("CLM", "A102059551", "0152035", "0151488",
            "ELEC", "NMEM", "FUTURE", "Y2", "381", "Equity indices", "IFLL", "ER");
    final Optional<UUID> result = Evaluator.singleEvaluate(inputs, now, node);
    assertTrue(result.isPresent());
    assertEquals(new UUID(0, 1L), result.get());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:51,代码来源:DatedEvaluatorTest.java

示例13: minus_Duration_overflowTooBig

import java.time.Instant; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void minus_Duration_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minus(Duration.ofSeconds(-1, 999999999));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKInstant.java

示例14: minus_Duration_overflowTooSmall

import java.time.Instant; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void minus_Duration_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND);
    i.minus(Duration.ofSeconds(0, 1));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKInstant.java

示例15: getStaleTime

import java.time.Instant; //导入方法依赖的package包/类
private Instant getStaleTime(Instant expiration) {
    return expiration == null ? null
                              : expiration.minus(Duration.ofMinutes(1));
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:5,代码来源:HttpCredentialsProvider.java


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