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


Java ZonedDateTime.now方法代码示例

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


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

示例1: should_wait_betweentasktimeout_when_task_found

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void should_wait_betweentasktimeout_when_task_found() throws Exception {
    Duration betweenTaskTimeout = Duration.ofHours(1L);
    Duration noTaskTimeout = Duration.ofMillis(5L);

    FakeExecutor executor = spy(new FakeExecutor());
    QueueConsumer queueConsumer = mock(QueueConsumer.class);
    TaskPicker taskPicker = mock(TaskPicker.class);
    TaskRecord taskRecord = new TaskRecord(0, null, 0, ZonedDateTime.now(),
            ZonedDateTime.now(), null, null);
    when(taskPicker.pickTask(queueConsumer)).thenReturn(taskRecord);
    TaskProcessor taskProcessor = mock(TaskProcessor.class);


    when(queueConsumer.getQueueConfig()).thenReturn(new QueueConfig(testLocation1,
            QueueSettings.builder().withBetweenTaskTimeout(betweenTaskTimeout).withNoTaskTimeout(noTaskTimeout).build()));
    QueueProcessingStatus status = new QueueRunnerInExternalExecutor(taskPicker, taskProcessor, executor).runQueue(queueConsumer);

    assertThat(status, equalTo(QueueProcessingStatus.PROCESSED));

    verify(executor).execute(Matchers.any());
    verify(taskPicker).pickTask(queueConsumer);
    verify(taskProcessor).processTask(queueConsumer, taskRecord);
}
 
开发者ID:yandex-money,项目名称:db-queue,代码行数:25,代码来源:QueueRunnerInExternalExecutorTest.java

示例2: queryDay

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private Parameters queryDay(Date day, int maxdocs) {
	Calendar c = new GregorianCalendar();
	c.setTime(day);
	c.set(Calendar.HOUR_OF_DAY, 0);
	c.set(Calendar.MINUTE, 0);
	c.set(Calendar.SECOND, 0);
	c.set(Calendar.MILLISECOND, 0);
	ZonedDateTime start = c.toInstant().atZone(ZoneId.systemDefault());

	c.add(Calendar.DAY_OF_MONTH, 1);
	ZonedDateTime end = c.toInstant().atZone(ZoneId.systemDefault());

	ZonedDateTime now = ZonedDateTime.now();
	long fromMinutes = (long) Math.ceil(Duration.between(start, now).get(ChronoUnit.SECONDS) / 60.);
	long toMinutes = (long) Math.ceil(Duration.between(end, now).get(ChronoUnit.SECONDS) / 60.);

	return query(fromMinutes, toMinutes, maxdocs);
}
 
开发者ID:ina-foss,项目名称:afp-api-client,代码行数:19,代码来源:AFPDataGrabber.java

示例3: reenqueue_should_update_process_time

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void reenqueue_should_update_process_time() throws Exception {
    QueueLocation location = generateUniqueLocation();
    String actor = "abc123";
    Long enqueueId = executeInTransaction(() ->
            queueDao.enqueue(location, new EnqueueParams<String>().withActor(actor)));

    ZonedDateTime beforeExecution = ZonedDateTime.now();
    Duration executionDelay = Duration.ofHours(1L);
    Boolean reenqueueResult = executeInTransaction(() -> queueActorDao.reenqueue(location, actor, executionDelay));
    Assert.assertThat(reenqueueResult, equalTo(true));
    jdbcTemplate.query("select * from " + QueueDatabaseInitializer.DEFAULT_TABLE_NAME + " where id=" + enqueueId, rs -> {
        ZonedDateTime afterExecution = ZonedDateTime.now();
        Assert.assertThat(rs.next(), equalTo(true));
        ZonedDateTime processTime = ZonedDateTime.ofInstant(rs.getTimestamp("process_time").toInstant(),
                ZoneId.systemDefault());

        Assert.assertThat(processTime.isAfter(beforeExecution.plus(executionDelay)), equalTo(true));
        Assert.assertThat(processTime.isBefore(afterExecution.plus(executionDelay)), equalTo(true));
        return new Object();
    });
}
 
开发者ID:yandex-money,项目名称:db-queue,代码行数:23,代码来源:QueueActorDaoTest.java

示例4: archiveerBijhoudingsNotificatieBericht

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public void archiveerBijhoudingsNotificatieBericht(final BijhoudingsplanNotificatieBericht bijhoudingsplanNotificatieBericht) {
    LOGGER.info("Archiveren van uitgaand bijhoudingsnotificatiebericht mbt partij : {}", bijhoudingsplanNotificatieBericht.getZendendePartijCode());
    final ArchiveringOpdracht archiveringOpdracht = new ArchiveringOpdracht(Richting.UITGAAND, ZonedDateTime.now());
    archiveringOpdracht.setSoortBericht(SoortBericht.BHG_SYS_VERWERK_BIJHOUDINGSPLAN);
    archiveringOpdracht.setOntvangendePartijId(partijCache.geefPartij(bijhoudingsplanNotificatieBericht.getOntvangendePartijCode()).getId());
    archiveringOpdracht.setZendendePartijId(partijCache.geefPartij(bijhoudingsplanNotificatieBericht.getZendendePartijCode()).getId());
    archiveringOpdracht.setZendendeSysteem(bijhoudingsplanNotificatieBericht.getZendendeSysteem());
    archiveringOpdracht.setReferentienummer(bijhoudingsplanNotificatieBericht.getReferentieNummer());
    archiveringOpdracht.setCrossReferentienummer(bijhoudingsplanNotificatieBericht.getCrossReferentieNummer());
    archiveringOpdracht.setTijdstipVerzending(DatumUtil.vanLongNaarZonedDateTime(bijhoudingsplanNotificatieBericht.getTijdstipVerzending()));
    archiveringOpdracht.setAdministratieveHandelingId(bijhoudingsplanNotificatieBericht.getAdministratieveHandelingId());
    archiveringOpdracht.setData(bijhoudingsplanNotificatieBericht.getVerwerkBijhoudingsplanBericht());
    archiveringOpdracht.setVerwerkingswijze(Verwerkingswijze.BIJHOUDING);
    archiefService.archiveer(archiveringOpdracht);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:17,代码来源:ArchiveerBerichtStapImpl.java

示例5: buildStatistic

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private Statistics.Statistic buildStatistic() throws DatatypeConfigurationException {

        //use system time as class under test has logic based on system time
        ZonedDateTime time = ZonedDateTime.now(ZoneOffset.UTC);

        Statistics.Statistic statistic = StatisticsHelper.buildValueStatistic(
                time,
                10.5,
                StatisticsHelper.buildTagType(tag1, tag1val1),
                StatisticsHelper.buildTagType(tag2, tag2val1)
        );
        StatisticsHelper.addIdentifier(statistic, id1part1, id1part2);
        StatisticsHelper.addIdentifier(statistic, id2part1, id2part2);

        return statistic;
    }
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:17,代码来源:TestValueStatToAggregateFlatMapper.java

示例6: isValid

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Check to see if punishment was cancelled or is over
 * @return true if punishment is still in effect
 */
public boolean isValid() {
    if(cancelled)
        return false;
    ZonedDateTime now = ZonedDateTime.now();
    return endTime.isAfter(now);
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:11,代码来源:Punishment.java

示例7: buildConditions

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Build conditions conditions.
 *
 * @param authnRequest the authn request
 * @param assertion    the assertion
 * @param service      the service
 * @param adaptor      the adaptor
 * @return the conditions
 * @throws SamlException the saml exception
 */
protected Conditions buildConditions(final AuthnRequest authnRequest,
                                     final Assertion assertion,
                                     final SamlRegisteredService service,
                                     final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) throws SamlException {

    final ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneOffset.UTC);
    final Conditions conditions = newConditions(currentDateTime,
            currentDateTime.plusSeconds(casProperties.getAuthn().getSamlIdp().getResponse().getSkewAllowance()),
            adaptor.getEntityId());
    return conditions;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:SamlProfileSamlConditionsBuilder.java

示例8: constructSamlResponse

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Construct SAML response.
 * <a href="http://bit.ly/1uI8Ggu">See this reference for more info.</a>
 *
 * @param service the service
 * @return the SAML response
 */
protected String constructSamlResponse(final GoogleAccountsService service) {
    final ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneOffset.UTC);
    final ZonedDateTime notBeforeIssueInstant = ZonedDateTime.parse("2003-04-17T00:46:02Z");
    final RegisteredService registeredService = servicesManager.findServiceBy(service);
    if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
        throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE);
    }
    final String userId = registeredService.getUsernameAttributeProvider().resolveUsername(service.getPrincipal(), service, registeredService);

    final org.opensaml.saml.saml2.core.Response response = this.samlObjectBuilder.newResponse(
            this.samlObjectBuilder.generateSecureRandomId(), currentDateTime, null, service);
    response.setStatus(this.samlObjectBuilder.newStatus(StatusCode.SUCCESS, null));

    final String sessionIndex = '_' + String.valueOf(Math.abs(new SecureRandom().nextLong()));
    final AuthnStatement authnStatement = this.samlObjectBuilder.newAuthnStatement(AuthnContext.PASSWORD_AUTHN_CTX, currentDateTime, sessionIndex);
    final Assertion assertion = this.samlObjectBuilder.newAssertion(authnStatement, casServerPrefix,
            notBeforeIssueInstant, this.samlObjectBuilder.generateSecureRandomId());

    final Conditions conditions = this.samlObjectBuilder.newConditions(notBeforeIssueInstant,
            currentDateTime.plusSeconds(this.skewAllowance), service.getId());
    assertion.setConditions(conditions);

    final Subject subject = this.samlObjectBuilder.newSubject(NameID.EMAIL, userId,
            service.getId(), currentDateTime.plusSeconds(this.skewAllowance), service.getRequestId());
    assertion.setSubject(subject);

    response.getAssertions().add(assertion);

    final StringWriter writer = new StringWriter();
    this.samlObjectBuilder.marshalSamlXmlObject(response, writer);

    final String result = writer.toString();
    LOGGER.debug("Generated Google SAML response: [{}]", result);
    return result;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:43,代码来源:GoogleAccountsServiceResponseBuilder.java

示例9: assertPojoMethodsForFill

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private void assertPojoMethodsForFill(Method method[]){
    final Object[] constructorParameters = {1L, "string1", "string2", Double.valueOf(2), null, 4.0, Double.valueOf(5), ZonedDateTime.now()};
    final Class[] constructorParameterTypes = {Long.class, String.class, String.class, Double.class, Double.class, double.class, Double.class, ZonedDateTime.class};
    assertPojoMethodsFor(classUnderTest)
            .create(classUnderTest, constructorParameters, constructorParameterTypes)
            .testing(method)
            .areWellImplemented();
}
 
开发者ID:CCob,项目名称:bittrex4j,代码行数:9,代码来源:DaoTests.java

示例10: now

import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime now() {
    try {
        return ZonedDateTime.now(ZoneId.systemDefault());
    } catch (Throwable e) {
        return utcNow();
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:8,代码来源:DateUtil.java

示例11: isUnclaimedCase

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private boolean isUnclaimedCase(GameServer s, String key) {
    if (s.getExpirationDate() == null) {
        return false;
    }
    ZonedDateTime now = ZonedDateTime.now();
    return "unclaimed".equals(key) && now.isAfter(s.getExpirationDate());
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:8,代码来源:GameServerService.java

示例12: testFindNotActivatedUsersByCreationDateBefore

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void testFindNotActivatedUsersByCreationDateBefore() {
    userService.removeNotActivatedUsers();
    ZonedDateTime now = ZonedDateTime.now();
    List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
    assertThat(users).isEmpty();
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:8,代码来源:UserServiceTest.java

示例13: removeNotActivatedUsers

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Not activated users should be automatically deleted after 3 days.
 * <p>
 * This is scheduled to get fired everyday, at 01:00 (am).
 * </p>
 */
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
    ZonedDateTime now = ZonedDateTime.now();
    List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
    for (User user : users) {
        log.debug("Deleting not activated user {}", user.getLogin());
        userRepository.delete(user);
        userSearchRepository.delete(user);
    }
}
 
开发者ID:klask-io,项目名称:klask-io,代码行数:17,代码来源:UserService.java

示例14: now_ZoneId_nullZoneId

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void now_ZoneId_nullZoneId() {
    ZonedDateTime.now((ZoneId) null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKZonedDateTime.java

示例15: getCurrentDateTimeWithTimeZone

import java.time.ZonedDateTime; //导入方法依赖的package包/类
protected String getCurrentDateTimeWithTimeZone() {
    final ZonedDateTime localDateTime = ZonedDateTime.now();
    return localDateTime.toString();
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:5,代码来源:DefaultStatsCollector.java


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