@Override public ZonedDateTime getNextTriggerTime(ZonedDateTime zonedNow, ZoneId zoneId) { ZonedDateTime zonedStartAt = buildZonedStartAt(zonedNow, zoneId); return zonedStartAt.isAfter(zonedNow) ? zonedStartAt : zonedStartAt.plusDays(1); } }
LocalDateTime localNow = LocalDateTime.now(); ZoneId currentZone = ZoneId.of("America/Los_Angeles"); ZonedDateTime zonedNow = ZonedDateTime.of(localNow, currentZone); ZonedDateTime zonedNext5 ; zonedNext5 = zonedNow.withHour(5).withMinute(0).withSecond(0); if(zonedNow.compareTo(zonedNext5) > 0) zonedNext5 = zonedNext5.plusDays(1); Duration duration = Duration.between(zonedNow, zonedNext5); long initalDelay = duration.getSeconds(); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); scheduler.scheduleAtFixedRate(new MyRunnableTask(), initalDelay, 24*60*60, TimeUnit.SECONDS);
@Test public void startAndEndDateCanIncludeLogs() throws Exception { ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault()); ZonedDateTime yesterday = now.minusDays(1); ZonedDateTime tomorrow = now.plusDays(1); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT); CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs"); commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday)); commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow)); commandStringBuilder.addOption("log-level", "debug"); gfshConnector.executeAndAssertThat(commandStringBuilder.toString()).statusIsSuccess(); Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet()); verifyZipFileContents(acceptedLogLevels); }
@Test public void startAndEndDateCanExcludeLogs() throws Exception { connectIfNeeded(); ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault()); ZonedDateTime tomorrow = now.plusDays(1); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT); CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs"); commandStringBuilder.addOption("start-time", dateTimeFormatter.format(tomorrow)); commandStringBuilder.addOption("log-level", "debug"); connector.executeAndAssertThat(commandStringBuilder.toString()).statusIsError() .containsOutput("No files to be exported"); }
ZonedDateTime zonedNextTarget = zonedNow.withHour(targetHour).withMinute(targetMin).withSecond(targetSec); if(zonedNow.compareTo(zonedNextTarget) > 0) zonedNextTarget = zonedNextTarget.plusDays(1);
public ZonedDateTime plusDays(long amount) { return dt.plusDays(amount); }
@Bean public RouteLocator testRouteLocator(RouteLocatorBuilder builder) { return builder.routes() .route("test_between_valid", r -> r.host("**.betweenvalid.org") .and().between(ZonedDateTime.now().minusDays(1), ZonedDateTime.now().plusDays(1)) .filters(f -> f.prefixPath("/httpbin")) .uri(uri)) .build(); } }
@Override public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layoutHandle, SplitSchedulingStrategy splitSchedulingStrategy) { AtopTableLayoutHandle handle = (AtopTableLayoutHandle) layoutHandle; AtopTableHandle table = handle.getTableHandle(); List<ConnectorSplit> splits = new ArrayList<>(); ZonedDateTime end = ZonedDateTime.now(timeZone); for (Node node : nodeManager.getWorkerNodes()) { ZonedDateTime start = end.minusDays(maxHistoryDays - 1).withHour(0).withMinute(0).withSecond(0).withNano(0); while (start.isBefore(end)) { ZonedDateTime splitEnd = start.withHour(23).withMinute(59).withSecond(59).withNano(0); Domain splitDomain = Domain.create(ValueSet.ofRanges(Range.range(TIMESTAMP_WITH_TIME_ZONE, 1000 * start.toEpochSecond(), true, 1000 * splitEnd.toEpochSecond(), true)), false); if (handle.getStartTimeConstraint().overlaps(splitDomain) && handle.getEndTimeConstraint().overlaps(splitDomain)) { splits.add(new AtopSplit(table.getTable(), node.getHostAndPort(), start.toEpochSecond(), start.getZone())); } start = start.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0); } } return new FixedSplitSource(splits); } }
@Override public ZonedDateTime getNextTriggerTime(ZonedDateTime zonedNow, ZoneId zoneId) { ZonedDateTime zonedStartAt = buildZonedStartAt(zonedNow, zoneId); switch (dayOfMonth) { case LAST: zonedStartAt = zonedStartAt.with(TemporalAdjusters.lastDayOfMonth()); return zonedStartAt.isAfter(zonedNow) ? zonedStartAt : zonedStartAt.plusDays(1).with(TemporalAdjusters.lastDayOfMonth()); case FIRST: default: zonedStartAt = zonedStartAt.with(TemporalAdjusters.firstDayOfMonth()); return zonedStartAt.isAfter(zonedNow) ? zonedStartAt : zonedStartAt.with(TemporalAdjusters.firstDayOfNextMonth()); } } }
if(inputDateWithCurrentYear.isAfter(currentDate.plusDays(4L))) { ZonedDateTime inputDateWithPreviousYear = ZonedDateTime.of(currentYear-1, inputMonth, inputDay, inputHour, inputMinute, inputSecond, 0, deviceTimeZone);
final ZonedDateTime input = ZonedDateTime.now(); System.out.println(input); final ZonedDateTime startOfLastWeek = input.minusWeeks(1).with(DayOfWeek.MONDAY); System.out.println(startOfLastWeek); final ZonedDateTime endOfLastWeek = startOfLastWeek.plusDays(6); System.out.println(endOfLastWeek);
public static long offsetCurrentTimeMillis(int offsetDays, int hour, int minute, int secord) { ZonedDateTime ldt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(currentTimeMillis()), ZoneId.systemDefault()); if (offsetDays > 0) { ldt = ldt.plusDays(offsetDays); } else if (offsetDays < 0) { ldt = ldt.minusDays(offsetDays); } ldt = ldt.withHour(hour); ldt = ldt.withMinute(minute); ldt = ldt.withSecond(secord); return ldt.toEpochSecond() * 1000; }
static Contract createSimpleContract(PrivateKey key) { Contract result = new Contract(); // default expiration date result.setExpiresAt(ZonedDateTime.now().plusDays(90)); // issuer role is a key for a new contract result.setIssuerKeys(key.getPublicKey().getShortAddress()); // issuer is owner, link roles result.registerRole(new RoleLink("owner", "issuer")); result.registerRole(new RoleLink("creator", "issuer")); return result; }
public void coverage() { SabrParametersIborCapletFloorletVolatilities test1 = SabrParametersIborCapletFloorletVolatilities.of(NAME, EUR_EURIBOR_3M, DATE_TIME, PARAM); coverImmutableBean(test1); SabrParametersIborCapletFloorletVolatilities test2 = SabrParametersIborCapletFloorletVolatilities.of( NAME2, IborIndices.EUR_LIBOR_3M, DATE_TIME.plusDays(1), IborCapletFloorletSabrRateVolatilityDataSet.SABR_PARAM_FLAT); coverBeanEquals(test1, test2); }
public void coverage() { NormalIborFutureOptionExpirySimpleMoneynessVolatilities test = NormalIborFutureOptionExpirySimpleMoneynessVolatilities.of(EUR_EURIBOR_3M, VAL_DATE_TIME, PARAMETERS_RATE); coverImmutableBean(test); NormalIborFutureOptionExpirySimpleMoneynessVolatilities test2 = NormalIborFutureOptionExpirySimpleMoneynessVolatilities.of( EUR_EURIBOR_6M, VAL_DATE_TIME.plusDays(1), PARAMETERS_PRICE); coverBeanEquals(test, test2); }
public void coverage() { SabrParametersSwaptionVolatilities test1 = SabrParametersSwaptionVolatilities.of(NAME, CONV, DATE_TIME, PARAM); coverImmutableBean(test1); SabrParametersSwaptionVolatilities test2 = SabrParametersSwaptionVolatilities.of( NAME2, SwaptionSabrRateVolatilityDataSet.SWAP_CONVENTION_EUR, DATE_TIME.plusDays(1), SwaptionSabrRateVolatilityDataSet.SABR_PARAM_USD); coverBeanEquals(test1, test2); } }
public void coverage() { BlackBondFutureExpiryLogMoneynessVolatilities test1 = BlackBondFutureExpiryLogMoneynessVolatilities.of( VAL_DATE_TIME, SURFACE); coverImmutableBean(test1); BlackBondFutureExpiryLogMoneynessVolatilities test2 = BlackBondFutureExpiryLogMoneynessVolatilities.of( VAL_DATE_TIME.plusDays(1), SURFACE.withParameter(0, 1d)); coverBeanEquals(test1, test2); }
public void coverage() { HullWhiteOneFactorPiecewiseConstantParametersProvider test1 = HullWhiteOneFactorPiecewiseConstantParametersProvider.of(PARAMETERS, ACT_360, DATE_TIME); coverImmutableBean(test1); HullWhiteOneFactorPiecewiseConstantParameters params = HullWhiteOneFactorPiecewiseConstantParameters.of( 0.02, DoubleArray.of(0.01, 0.011, 0.014), DoubleArray.of(0.5, 5.0)); HullWhiteOneFactorPiecewiseConstantParametersProvider test2 = HullWhiteOneFactorPiecewiseConstantParametersProvider.of(params, ACT_ACT_ISDA, DATE_TIME.plusDays(1)); coverBeanEquals(test1, test2); }