List of usage examples for java.time OffsetDateTime toInstant
public Instant toInstant()
From source file:org.silverpeas.components.gallery.notification.user.AlbumMediaNotificationManagerTest.java
private void assertJobScheduled(final JobTrigger jobTrigger, final OffsetDateTime nowReference, final long delayOffset) { final long delayInMilliseconds = jobTrigger.getStartDate().getTime() - Date.from(nowReference.toInstant()).getTime() - delayOffset; assertThat(delayInMilliseconds, greaterThanOrEqualTo(10000L)); assertThat(delayInMilliseconds, lessThanOrEqualTo(11000L)); verify(userNotificationManager, times(0)) .buildAndSend(any(GalleryAlbumMediaSubscriptionNotificationBuilder.class)); }
From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java
/** * Checks if scheduler's time data satisfies existing time parameters. * * @param dto scheduler job data. * @param dateTime existing time data. * @param desiredStatus target exploratory status which has influence for time/date checking ('running' status * requires for checking start time, 'stopped' - for end time, 'terminated' - for * 'terminatedDateTime'). * @return true/false./* ww w . j a v a 2 s . co m*/ */ private boolean isSchedulerJobDtoSatisfyCondition(SchedulerJobDTO dto, OffsetDateTime dateTime, UserInstanceStatus desiredStatus) { ZoneOffset zOffset = dto.getTimeZoneOffset(); OffsetDateTime roundedDateTime = OffsetDateTime.of(dateTime.toLocalDate(), LocalTime.of(dateTime.toLocalTime().getHour(), dateTime.toLocalTime().getMinute()), dateTime.getOffset()); LocalDateTime convertedDateTime = ZonedDateTime .ofInstant(roundedDateTime.toInstant(), ZoneId.ofOffset(TIMEZONE_PREFIX, zOffset)) .toLocalDateTime(); return desiredStatus == TERMINATED ? Objects.nonNull(dto.getTerminateDateTime()) && convertedDateTime.toLocalDate().equals(dto.getTerminateDateTime().toLocalDate()) && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus)) : !convertedDateTime.toLocalDate().isBefore(dto.getBeginDate()) && isFinishDateMatchesCondition(dto, convertedDateTime) && getDaysRepeat(dto, desiredStatus) .contains(convertedDateTime.toLocalDate().getDayOfWeek()) && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus)); }
From source file:it.ozimov.springboot.templating.mail.service.PriorityQueueSchedulerService.java
@Override public synchronized void schedule(@NonNull final Email mimeEmail, @NonNull final OffsetDateTime scheduledDateTime, final int priorityLevel) { checkPriorityLevel(priorityLevel);//from w w w. j a v a2 s .co m final int realPriorityLevel = normalizePriority(priorityLevel); final EmailSchedulingWrapper emailSchedulingWrapper = new EmailSchedulingWrapper(mimeEmail, scheduledDateTime, realPriorityLevel); queues[priorityLevel - 1].add(emailSchedulingWrapper); log.info("Scheduled email {} at UTC time {} with priority {}", mimeEmail, scheduledDateTime, priorityLevel); if (isNull(timeOfNextScheduledMessage) || scheduledDateTime.toInstant().toEpochMilli() < timeOfNextScheduledMessage) { notify(); //the consumer, if waiting, is notified and can try to send next scheduled message } }
From source file:org.openbase.bco.ontology.lib.manager.aggregation.DataAggregation.java
public DataAggregation(final OffsetDateTime dateTimeFrom, final OffsetDateTime dateTimeUntil, final Period currentPeriod) throws CouldNotPerformException { if (currentPeriod == null) { throw new CouldNotPerformException( "Could not perform aggregation of aggregated data, because current period is null!"); }//from w ww .j a va 2 s .c om this.dateTimeFrom = dateTimeFrom; this.dateTimeUntil = dateTimeUntil; this.currentPeriod = currentPeriod; this.timeFrameMilliS = dateTimeUntil.toInstant().toEpochMilli() - dateTimeFrom.toInstant().toEpochMilli(); }
From source file:fi.hsl.parkandride.itest.PredictionITest.java
@Test public void prediction_JSON_structure() { Utilization u = makeDummyPredictions(); JsonPath json = when().get(UrlSchema.FACILITY_PREDICTION, facilityId).jsonPath(); long facilityId = json.getLong("[0].facilityId"); String capacityType = json.getString("[0].capacityType"); String usage = json.getString("[0].usage"); OffsetDateTime timestamp = OffsetDateTime.parse(json.getString("[0].timestamp"), DateTimeFormatter.ISO_OFFSET_DATE_TIME); int spacesAvailable = json.getInt("[0].spacesAvailable"); assertThat(facilityId).as("facilityId").isEqualTo(u.facilityId); assertThat(capacityType).as("capacityType").isEqualTo(u.capacityType.name()); assertThat(usage).as("usage").isEqualTo(u.usage.name()); assertThat(timestamp.getOffset()).as("time should be in local timezone") .isEqualTo(ZoneOffset.systemDefault().getRules().getOffset(timestamp.toInstant())); assertThat(spacesAvailable).as("spacesAvailable").isEqualTo(u.spacesAvailable); }
From source file:it.ozimov.springboot.templating.mail.service.PriorityQueueSchedulerService.java
@Override public synchronized void schedule(@NonNull final Email mimeEmail, @NonNull final OffsetDateTime scheduledDateTime, final int priorityLevel, @NonNull final String template, @NonNull final Map<String, Object> modelObject, final InlinePicture... inlinePictures) throws CannotSendEmailException { checkPriorityLevel(priorityLevel);/*from w w w . j a v a 2s .c o m*/ final int realPriorityLevel = normalizePriority(priorityLevel); final EmailTemplateSchedulingWrapper emailTemplateSchedulingWrapper = new EmailTemplateSchedulingWrapper( mimeEmail, scheduledDateTime, realPriorityLevel, template, modelObject, inlinePictures); queues[priorityLevel - 1].add(emailTemplateSchedulingWrapper); log.info("Scheduled email {} at UTC time {} with priority {} with template", mimeEmail, scheduledDateTime, priorityLevel); if (isNull(timeOfNextScheduledMessage) || scheduledDateTime.toInstant().toEpochMilli() < timeOfNextScheduledMessage) { notify(); } }