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


Java Instant.plus方法代码示例

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


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

示例1: testSixRules

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testSixRules() {
    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");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "*", "*", "UK", "*", start, finish, 6L, "1.1");

    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(inputD, now, node, 6L);
    checkMatch(inputE, now, node, 5L);
    checkMatch(inputF, now, node, 6L);
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:25,代码来源:DatedEvaluatorTest.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: hashCodeCorrect

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void hashCodeCorrect() {
    final Set<RuleChange> ruleChanges = null;
    final Set<ValueGroupChange> valueGroupChanges = null;

    final Instant initiatorTime = NOW;
    final Instant authoriserTime = initiatorTime.plus(Period.ofWeeks(1));

    final Audit audit = new Audit("USER1", initiatorTime, "USER2", authoriserTime);
    final Change change = new Change(new UUID(0, 2), "TEST-RULESET", NOW, CHANGE_RANGE, audit, ruleChanges,
            valueGroupChanges);

    final Audit otherAudit = new Audit("USER1", initiatorTime, "USER2", authoriserTime);
    final Change otherChange = new Change(new UUID(0, 2), "TEST-RULESET", NOW, CHANGE_RANGE, otherAudit,
            ruleChanges, valueGroupChanges);

    assertEquals(change.hashCode(), otherChange.hashCode());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:19,代码来源:ChangeTest.java

示例4: removesOldestEntry

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void removesOldestEntry() {
    final Instant now = Instant.now();

    final Range<Instant> rangeOne = new Range<>(now, now.plus(Period.ofWeeks(1)));
    this.cache.putIfAbsent(rangeOne, rangeOne);
    assertTrue(this.cache.containsKey(rangeOne));

    final Range<Instant> rangeTwo = new Range<>(now.plus(Period.ofWeeks(1)), now.plus(Period.ofWeeks(2)));
    this.cache.putIfAbsent(rangeTwo, rangeTwo);
    assertTrue(this.cache.containsKey(rangeOne));
    assertTrue(this.cache.containsKey(rangeTwo));

    this.cache.get(rangeTwo);

    final Range<Instant> rangeThree = new Range<>(now.plus(Period.ofWeeks(2)), now.plus(Period.ofWeeks(3)));
    this.cache.putIfAbsent(rangeThree, rangeThree);

    assertFalse(this.cache.containsKey(rangeOne));
    assertTrue(this.cache.containsKey(rangeTwo));
    assertTrue(this.cache.containsKey(rangeThree));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-jbl,代码行数:23,代码来源:LruCacheTest.java

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

示例6: hashCodeCorrect

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void hashCodeCorrect() {
    final Instant start = Instant.now().minus(Period.ofWeeks(-1));
    final Instant end = start.plus(Period.ofWeeks(5));
    final InputDriver[] drivers = getInputDriverArray("Test1", "Test2", "Test3");
    final Map<String, String> outputs = Collections.singletonMap("outputDriver", "result");

    final DecisionTreeRule rule =
            new DecisionTreeRule(new UUID(0, 1), new UUID(0, 2), drivers, outputs, start, end);
    final RuleChange ruleChange = new RuleChange(Type.ORIGINAL, rule);

    final DecisionTreeRule otherRule =
            new DecisionTreeRule(new UUID(0, 1), new UUID(0, 2), drivers, outputs, start, end);
    final RuleChange otherRuleChange = new RuleChange(Type.ORIGINAL, otherRule);

    assertEquals(ruleChange.hashCode(), otherRuleChange.hashCode());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:18,代码来源:RuleChangeTest.java

示例7: changeAuditInfo

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void changeAuditInfo() {
    testConstruction();

    Instant initiatorTime = NOW;

    final Audit audit = getBean().getAudit();
    assertEquals("USER1", audit.getInitiator());
    assertEquals(initiatorTime, audit.getInitiatorTime());
    assertEquals("USER2", audit.getAuthoriser());

    Instant authoriserTime = initiatorTime.plus(Period.ofWeeks(1));
    assertEquals(authoriserTime, audit.getAuthoriserTime());

    initiatorTime = NOW.plus(Period.ofWeeks(5));
    authoriserTime = initiatorTime.plus(Period.ofWeeks(1));
    final Audit newAudit = new Audit("USER3", initiatorTime, "USER4", authoriserTime);
    getBean().setAudit(newAudit);

    this.injectedValues.clear();

    this.injectedValues.put("initiator", "USER3");
    this.injectedValues.put("initiatorTime", initiatorTime);
    this.injectedValues.put("authoriser", "USER4");
    this.injectedValues.put("authoriserTime", authoriserTime);

    JblTestClassUtils.assertGetterCorrectForConstructorInjection(this.injectedValues, getBean().getAudit());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:29,代码来源:ChangeTest.java

示例8: generateToken

import java.time.Instant; //导入方法依赖的package包/类
String generateToken() {
	Instant now = Instant.now();
	Instant exp = now.plus(1, ChronoUnit.DAYS);

	JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
			.issuer(props.getExternalUrl() + "/oauth/token") //
			.expirationTime(Date.from(exp)) //
			.issueTime(Date.from(now)) //
			.claim("scope", Collections.singletonList("actuator.read")) //
			.build();

	return this.jwtTokenConverter.sign(claimsSet).serialize();
}
 
开发者ID:making,项目名称:spring-boot-actuator-dashboard,代码行数:14,代码来源:AccessTokenService.java

示例9: hashCodeCorrect

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void hashCodeCorrect() {
    final UUID id = new UUID(0, 1);
    final Instant start = Instant.now().minus(Period.ofWeeks(-1));
    final Instant end = start.plus(Period.ofWeeks(5));
    final DateRange range = new DateRange(start, end);
    final List<String> drivers = Arrays.asList("Test1", "Test2", "Test3");
    final ValueGroup valueGroup = new ValueGroup(id, "TestValueGroup", drivers, range);

    final ValueGroupChange change = new ValueGroupChange(Type.NEW, valueGroup);
    final ValueGroupChange other = new ValueGroupChange(Type.NEW, valueGroup);

    assertEquals(change.hashCode(), other.hashCode());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:15,代码来源:ValueGroupChangeTest.java

示例10: plus

import java.time.Instant; //导入方法依赖的package包/类
public static Instant plus(Instant instant, Duration add) {
    if(isInfFuture(instant)) {
        return INF_FUTURE;
    } else if(isInfPast(instant)) {
        return INF_PAST;
    } else if(isInfPositive(add)) {
        return INF_FUTURE;
    } else if(isInfNegative(add)) {
        return INF_PAST;
    } else {
        return instant.plus(add);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:14,代码来源:TimeUtils.java

示例11: removeValueGroup

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void removeValueGroup() {
    testConstruction();
    final Instant start = NOW.minus(Period.ofWeeks(-1));
    final Instant end = start.plus(Period.ofWeeks(5));
    final DateRange range = new DateRange(start, end);
    final List<String> drivers = Arrays.asList("Test5", "Test6", "Test7");
    final ValueGroup valueGroup = new ValueGroup(ADDED_ID, "TestValueGroup", drivers, range);
    final ValueGroupChange valueGroupChange = new ValueGroupChange(Type.NEW, valueGroup);

    getBean().addValueGroupChange(valueGroupChange);

    ValueGroup valueGroupForTest = new ValueGroup(UNKNOWN_ID, "TestValueGroup", drivers, range);
    ValueGroupChange valueGroupChangeForTest = new ValueGroupChange(Type.NEW, valueGroupForTest);
    getBean().removeValueGroupChange(valueGroupChangeForTest);
    assertThat(getBean().getValueGroupChanges(), hasSize(2));
    assertThat(getBean().getRuleChanges(), hasSize(1));

    valueGroupForTest = new ValueGroup(UNKNOWN_ID, "TestValueGroup", drivers, range);
    valueGroupChangeForTest = new ValueGroupChange(Type.ORIGINAL, valueGroupForTest);
    getBean().removeValueGroupChange(valueGroupChangeForTest);
    assertThat(getBean().getValueGroupChanges(), hasSize(2));
    assertThat(getBean().getRuleChanges(), hasSize(1));

    valueGroupForTest = new ValueGroup(ADDED_ID, "TestValueGroup", drivers, range);
    valueGroupChangeForTest = new ValueGroupChange(Type.ORIGINAL, valueGroupForTest);
    getBean().removeValueGroupChange(valueGroupChangeForTest);
    assertThat(getBean().getValueGroupChanges(), hasSize(2));
    assertThat(getBean().getRuleChanges(), hasSize(1));

    valueGroupForTest = new ValueGroup(ADDED_ID, "TestValueGroup", drivers, range);
    valueGroupChangeForTest = new ValueGroupChange(Type.NEW, valueGroupForTest);
    getBean().removeValueGroupChange(valueGroupChangeForTest);
    assertThat(getBean().getValueGroupChanges(), hasSize(1));
    assertThat(getBean().getRuleChanges(), hasSize(1));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:37,代码来源:ChangeTest.java

示例12: testCalculateInterval

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testCalculateInterval() throws Exception {

    Duration interval = Duration.ofMillis(10);
    Instant t1 = Instant.now();
    Instant t2 = t1.plus(interval);
    when(module.getMock(PropertyManager.class).getNow()).thenReturn(t1);

    assertEquals(target.calculateInterval(t2), interval);
    assertEquals(target.calculateInterval(t1), ZERO);
    assertEquals(target.calculateInterval(t1.minus(interval)), ZERO);
    assertEquals(target.calculateInterval(null), ZERO);

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:15,代码来源:TraderImplTest.java

示例13: testDateRange

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testDateRange() {
    final Instant startInstance = Instant.now().minus(1, ChronoUnit.DAYS);
    final Instant endInstance = startInstance.plus(2, ChronoUnit.DAYS);
    final DecisionTreeRule decisionTreeRule =
            new DecisionTreeRule(new UUID(0, 1), UUID.randomUUID(),
                    getInputDriverArray("DRIVER_ONE", "DRIVER_TWO"),
                    this.outputDriver, startInstance, endInstance);

    assertEquals(startInstance, decisionTreeRule.getRange().getStart());
    assertEquals(endInstance, decisionTreeRule.getRange().getFinish());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:13,代码来源:DecisionTreeRuleTest.java

示例14: addValueGroupChange

import java.time.Instant; //导入方法依赖的package包/类
@Test
public void addValueGroupChange() {
    testConstruction();
    final Instant start = NOW.minus(Period.ofWeeks(-1));
    final Instant end = start.plus(Period.ofWeeks(5));
    final DateRange range = new DateRange(start, end);
    final List<String> drivers = Arrays.asList("Test5", "Test6", "Test7");
    final ValueGroup valueGroup = new ValueGroup(ADDED_ID, "TestValueGroup", drivers, range);
    final ValueGroupChange valueGroupChange = new ValueGroupChange(Type.NEW, valueGroup);

    final ValueGroup originalValueGroupChanged = new ValueGroup(BASE_ID, "TestValueGroup",
            Arrays.asList("Test2", "Test3"), range);
    final ValueGroupChange originalValueGroupChange = new ValueGroupChange(Type.NEW, originalValueGroupChanged);

    getBean().addValueGroupChange(valueGroupChange);
    getBean().addValueGroupChange(originalValueGroupChange);
    assertThat(getBean().getValueGroupChanges(), hasSize(3));
    assertThat(getBean().getValueGroupChanges(), hasItems(getBean().getValueGroupChanges().iterator().next(),
            valueGroupChange, originalValueGroupChange));
    assertThat(getBean().getRuleChanges(), hasSize(1));

    final Map<UUID, Optional<TreeValueGroup>> groups = getBean().getGroups();
    assertNotNull(groups);
    assertThat(groups.size(), is(2));
    assertThat(groups, allOf(
            hasEntry(BASE_ID, Optional.<TreeValueGroup>of(originalValueGroupChanged)),
            hasEntry(ADDED_ID, Optional.<TreeValueGroup>of(valueGroup))));

}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:30,代码来源:ChangeTest.java

示例15: plus_longTemporalUnit_overflowTooSmall

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


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