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


Java ZonedDateTime.plusSeconds方法代码示例

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


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

示例1: testSplitZonedDateTimes

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(dataProvider = "directions")
public void testSplitZonedDateTimes(boolean ascending) {
    final Duration step = Duration.ofSeconds(1);
    final ZonedDateTime start = ZonedDateTime.of(2014, 1, 1, 14, 15, 20, 0, ZoneId.systemDefault());
    final ZonedDateTime end = start.plusSeconds(10000000 * (ascending ? 1 : -1));
    final Range<ZonedDateTime> range = Range.of(start, end, step);
    final List<Range<ZonedDateTime>> segments = range.split();
    Assert.assertTrue(segments.size() > 1, "There are multiple segments");
    for (int i=1; i<segments.size(); ++i) {
        final Range<ZonedDateTime> prior = segments.get(i-1);
        final Range<ZonedDateTime> next = segments.get(i);
        Assert.assertEquals(prior.end(), next.start(), "Date connect as expect");
        if (i == 1) Assert.assertEquals(prior.start(), range.start(), "First segment start matches range start");
        if (i == segments.size()-1) {
            Assert.assertEquals(next.end(), range.end(), "Last segment end matches range end");
        }
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:19,代码来源:RangeSplitTests.java

示例2: test_plusSeconds_seconds

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void test_plusSeconds_seconds() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.plusSeconds(1);
    assertEquals(test, ZonedDateTime.of(ldt.plusSeconds(1), ZONE_0100));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKZonedDateTime.java

示例3: should_run_job_with_success_status

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void should_run_job_with_success_status() throws Throwable {
    // given:
    final String sessionId = "session-id-1";
    Node root = createRootFlow("flow_run_job", "yml/for_job_service_run_job.yml");

    // when: create job and job should be SESSION_CREATING
    Job job = createMockJob(root.getPath());
    verify(exactly(1), postRequestedFor(urlEqualTo("/cmd/queue/send?priority=1&retry=5")));

    // when: simulate cc callback for create session
    Cmd cmd = new Cmd("default", null, CmdType.CREATE_SESSION, null);
    cmd.setSessionId(sessionId);
    cmd.setStatus(CmdStatus.SENT);
    CmdCallbackQueueItem createSessionItem = new CmdCallbackQueueItem(job.getId(), cmd);
    jobService.callback(createSessionItem);
    verify(exactly(1), postRequestedFor(urlEqualTo("/cmd/send")));

    // then: check job status should be running
    job = reload(job);
    Assert.assertEquals(sessionId, job.getSessionId());
    Assert.assertEquals(JobStatus.RUNNING, job.getStatus());

    // then: check job tree data is correct
    NodeTree tree = jobNodeService.get(job);
    List<Node> steps = tree.children();
    Assert.assertEquals(7, steps.size());

    // when: simulate callback for all steps
    int numOfRequestForCmdSend = 2;
    for (Node step : steps) {
        NodeResult stepResult = nodeResultService.find(step.getPath(), job.getId());

        // check step root status should be success
        if (!tree.canRun(step.getPath())) {
            Assert.assertEquals(NodeStatus.SUCCESS, stepResult.getStatus());
            Assert.assertEquals(60L, stepResult.getDuration().longValue());
            continue;
        }

        Assert.assertEquals(NodeStatus.PENDING, stepResult.getStatus());

        // simulate callback with success executed
        Cmd stepCmd = new Cmd("default", null, CmdType.RUN_SHELL, nodeService.getRunningScript(step));
        stepCmd.setSessionId(sessionId);
        stepCmd.setStatus(CmdStatus.LOGGED);
        stepCmd.setCmdResult(new CmdResult(0));
        stepCmd.setExtra(step.getPath());

        // set start and finish time for 30 seconds of every steps
        ZonedDateTime start = ZonedDateTime.now();
        ZonedDateTime finish = start.plusSeconds(30);
        stepCmd.getCmdResult().setStartTime(start);
        stepCmd.getCmdResult().setFinishTime(finish);

        // build mock identifier
        CmdCallbackQueueItem runStepShellItem = new CmdCallbackQueueItem(job.getId(), stepCmd);
        jobService.callback(runStepShellItem);
        stepResult = nodeResultService.find(step.getPath(), job.getId());
        Assert.assertEquals(NodeStatus.SUCCESS, stepResult.getStatus());

        verify(exactly(numOfRequestForCmdSend++), postRequestedFor(urlEqualTo("/cmd/send")));

        verify(moreThanOrExactly(1),
            postRequestedFor(urlEqualTo("/cmd/send"))
                .withRequestBody(matchingJsonPath("$.inputs[?(@.FLOW_JOB_LAST_STATUS == 'SUCCESS')]")));
    }

    // then: check num of cmd request to run shell, 5 steps + 1 del session requests
    verify(exactly(6), postRequestedFor(urlEqualTo("/cmd/send")));

    // then: check job status
    job = reload(job);
    Assert.assertEquals(JobStatus.SUCCESS, job.getStatus());
    Assert.assertEquals(NodeStatus.SUCCESS, job.getRootResult().getStatus());
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:77,代码来源:JobServiceTest.java

示例4: calculateExpirationDate

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Calculate the expiration date for a token.
 *
 * @param issuedDate
 * @return
 */
private ZonedDateTime calculateExpirationDate(ZonedDateTime issuedDate) {
    return issuedDate.plusSeconds(validFor);
}
 
开发者ID:cassiomolin,项目名称:jersey-jwt-springsecurity,代码行数:10,代码来源:DefaultAuthenticationTokenService.java


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