@Override
 public JobModel from(UriInfo uriInfo, Job job) {
   JobModel jobModel = new JobModel();
   jobModel.setId(job.getId());
   jobModel.setName(job.getJobName());
   jobModel.setExternalIds(job.getExternalIds());
   jobModel.setType(job.getJobType().name());
   jobModel.setStatus(
       new ResourceStatusModel(
           job.getStatus().name(),
           ZonedDateTime.ofInstant(job.getStatusTimestamp().toInstant(), ZoneId.systemDefault())));
   jobModel.setPriority(job.getPriority());
   jobModel.setCreated(
       ZonedDateTime.ofInstant(job.getCreated().toInstant(), ZoneId.systemDefault()));
   jobModel.setCreatedBy(job.getCreatedBy());
   jobModel.setLastModified(
       ZonedDateTime.ofInstant(job.getLastModified().toInstant(), ZoneId.systemDefault()));
   jobModel.setLastModifiedBy(job.getLastModifiedBy());
   ImmutableMap.Builder<String, Href> builder = ImmutableMap.builder();
   builder.put("self", new Href(getJobResourceUrlAsString(uriInfo, job, null)));
   builder.put(
       "configuration", new Href(getJobResourceUrlAsString(uriInfo, job, "configuration")));
   builder.put("status", new Href(getJobResourceUrlAsString(uriInfo, job, "status")));
   jobModel.setLinks(builder.build());
   return jobModel;
 }
Ejemplo n.º 2
0
  public void printEvents(List<TimedEvent> events) {
    DateTimeFormatter isoLocalDate = DateTimeFormatter.ISO_LOCAL_DATE;
    DateTimeFormatter isoLocalTime = DateTimeFormatter.ISO_LOCAL_TIME;

    ZonedDateTime lastEventTime = ZonedDateTime.of(LocalDateTime.MIN, timeZone);

    for (Iterator<TimedEvent> iterator = events.iterator(); iterator.hasNext(); ) {
      TimedEvent timedEvent = (TimedEvent) iterator.next();
      ZonedDateTime timeCreated = timedEvent.getTimeCreated();

      // print a marker for each new day
      if (!timedEvent.isSameDay(lastEventTime)) {
        ps.print("------------ ");
        ps.print(timeCreated.format(isoLocalDate));
        ps.println(" ------------ ");
      }
      lastEventTime = timeCreated;

      ExtendedEventRecord eventRecord = timedEvent.getEventRecord();
      EventTypes eventType = EventTypes.fromInt(eventRecord.getEventId());
      String formattedTime = timeCreated.format(isoLocalTime);

      ps.println(String.format("%s: %s", formattedTime, eventType));
    }
  }
  /**
   * @param candleSeries
   * @param startPeriod
   * @return
   * @throws ClassNotFoundException
   * @throws InstantiationException
   * @throws IllegalAccessException
   * @throws NoSuchMethodException
   * @throws InvocationTargetException
   * @throws IOException
   * @throws PersistentModelException
   * @throws StrategyRuleException
   */
  public Candle getPreviousDayCandleFromDb(CandleSeries candleSeries, ZonedDateTime startPeriod)
      throws ClassNotFoundException, InstantiationException, IllegalAccessException,
          NoSuchMethodException, InvocationTargetException, IOException, PersistentModelException,
          StrategyRuleException {
    Candle prevCandle = null;

    this.tradePersistentModel =
        (PersistentModel)
            ClassFactory.getServiceForInterface(PersistentModel._persistentModel, this);

    long days = 1;
    if (DayOfWeek.MONDAY.equals((startPeriod.getDayOfWeek()))) {
      days = 3;
    }

    ZonedDateTime newStartPeriod = this.getTradestrategy().getTradingday().getOpen();
    List<Candle> candleList =
        this.tradePersistentModel.findCandlesByContractDateRangeBarSize(
            candleSeries.getContract().getIdContract(), newStartPeriod.minusDays(days),
            newStartPeriod.minusDays(days), candleSeries.getBarSize());

    if (candleList.size() > 0) {
      prevCandle = candleList.get(0);
    }

    return prevCandle;
  }
Ejemplo n.º 4
0
  public static void main(String[] args) {
    ZonedDateTime apollo11launch =
        ZonedDateTime.of(1969, 7, 16, 9, 32, 0, 0, ZoneId.of("America/New_York"));

    String formatted = DateTimeFormatter.ISO_DATE_TIME.format(apollo11launch);
    // 1969-07-16T09:32:00-05:00[America/New_York]
    System.out.println(formatted);

    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG);
    formatted = formatter.format(apollo11launch);
    // July 16, 1969 9:32:00 AM EDT
    System.out.println(formatted);
    formatted = formatter.withLocale(Locale.FRENCH).format(apollo11launch);
    // 16 juillet 1969 09:32:00 EDT
    System.out.println(formatted);

    formatter = DateTimeFormatter.ofPattern("E yyyy-MM-dd HH:mm");
    formatted = formatter.format(apollo11launch);
    System.out.println(formatted);

    LocalDate churchsBirthday = LocalDate.parse("1903-06-14");
    System.out.println("churchsBirthday: " + churchsBirthday);
    apollo11launch =
        ZonedDateTime.parse(
            "1969-07-16 03:32:00-0400", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssxx"));
    System.out.println("apollo11launch: " + apollo11launch);
  }
  @Test
  @Transactional
  public void getBloodPressureForLast30Days() throws Exception {
    ZonedDateTime now = ZonedDateTime.now();
    ZonedDateTime firstOfMonth = now.withDayOfMonth(1);
    ZonedDateTime firstDayOfLastMonth = firstOfMonth.minusMonths(1);
    createBloodPressureByMonth(firstOfMonth, firstDayOfLastMonth);

    // create security-aware mockMvc
    restBloodPressureMockMvc =
        MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build();

    // Get all the blood pressure readings
    restBloodPressureMockMvc
        .perform(get("/api/bloodPressures").with(user("user").roles("USER")))
        .andExpect(status().isOk())
        .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$", hasSize(6)));

    // Get the blood pressure readings for the last 30 days
    restBloodPressureMockMvc
        .perform(get("/api/bp-by-days/{days}", 30).with(user("user").roles("USER")))
        .andDo(print())
        .andExpect(status().isOk())
        .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.period").value("Last 30 Days"))
        .andExpect(jsonPath("$.readings.[*].systolic").value(hasItem(120)))
        .andExpect(jsonPath("$.readings.[*].diastolic").value(hasItem(75)));
  }
 // -------------------------------------------------------------------------
 @Override
 public double relativeTime(ZonedDateTime dateTime) {
   ArgChecker.notNull(dateTime, "dateTime");
   LocalDate valuationDate = valuationDateTime.toLocalDate();
   LocalDate date = dateTime.toLocalDate();
   return dayCount.relativeYearFraction(valuationDate, date);
 }
/**
 * Base abstract class for entities which will hold definitions for created, last modified by and
 * created, last modified by date.
 */
@MappedSuperclass
@Audited
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractAuditingEntity {

  @CreatedBy
  @NotNull
  @Column(name = "created_by", nullable = false, length = 50, updatable = false)
  @JsonIgnore
  private String createdBy;

  @CreatedDate
  @NotNull
  @Column(name = "created_date", nullable = false)
  @JsonIgnore
  private ZonedDateTime createdDate = ZonedDateTime.now();

  @LastModifiedBy
  @Column(name = "last_modified_by", length = 50)
  @JsonIgnore
  private String lastModifiedBy;

  @LastModifiedDate
  @Column(name = "last_modified_date")
  @JsonIgnore
  private ZonedDateTime lastModifiedDate = ZonedDateTime.now();

  public String getCreatedBy() {
    return createdBy;
  }

  public void setCreatedBy(String createdBy) {
    this.createdBy = createdBy;
  }

  public ZonedDateTime getCreatedDate() {
    return createdDate;
  }

  public void setCreatedDate(ZonedDateTime createdDate) {
    this.createdDate = createdDate;
  }

  public String getLastModifiedBy() {
    return lastModifiedBy;
  }

  public void setLastModifiedBy(String lastModifiedBy) {
    this.lastModifiedBy = lastModifiedBy;
  }

  public ZonedDateTime getLastModifiedDate() {
    return lastModifiedDate;
  }

  public void setLastModifiedDate(ZonedDateTime lastModifiedDate) {
    this.lastModifiedDate = lastModifiedDate;
  }
}
Ejemplo n.º 8
0
 @Test(dataProvider = "parseWithZoneWithOffset")
 public void testWithZoneWithOffset(
     String zdtString, LocalDateTime ldt, ZoneOffset offset, ZoneId zone) {
   dtFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
   zdt1 = ZonedDateTime.ofInstant(ldt, offset, zone);
   zdt2 = ZonedDateTime.parse(zdtString, dtFormatter);
   assertEquals(zdt1, zdt2);
 }
 @Theory
 public void test_isIn_assertion(ZonedDateTime referenceDate) {
   // WHEN
   assertThat(referenceDate)
       .isIn(referenceDate.toString(), referenceDate.plus(1, ChronoUnit.MILLIS).toString());
   // THEN
   verify_that_isIn_assertion_fails_and_throws_AssertionError(referenceDate);
 }
Ejemplo n.º 10
0
 @Test
 public void testFindNotActivatedUsersByCreationDateBefore() {
   userService.removeNotActivatedUsers();
   ZonedDateTime now = ZonedDateTime.now();
   List<User> users =
       userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
   assertThat(users).isEmpty();
 }
 @Theory
 public void test_isNotIn_assertion(ZonedDateTime referenceDate) {
   // WHEN
   assertThat(referenceDate)
       .isNotIn(referenceDate.plusNanos(1).toString(), referenceDate.plusNanos(2).toString());
   // THEN
   verify_that_isNotIn_assertion_fails_and_throws_AssertionError(referenceDate);
 }
  @Test
  public void testGetNextBusinessDay_Satruday() {
    ZonedDateTime ldt = ZonedDateTime.of(2016, 2, 27, 6, 45, 55, 0, ZoneId.systemDefault());
    ZonedDateTime expectedDatetime =
        ZonedDateTime.of(2016, 2, 29, 6, 30, 2, 0, ZoneId.systemDefault());
    strategy.exitTime = LocalTime.of(6, 30, 2);

    assertEquals(expectedDatetime, strategy.getNextBusinessDay(ldt));
  }
  @Test
  public void testGetNextBusinessDay_ExitSecondsSet() {
    ZonedDateTime ldt = ZonedDateTime.of(2016, 2, 25, 6, 45, 55, 0, ZoneId.systemDefault());
    ZonedDateTime expectedDatetime =
        ZonedDateTime.of(2016, 2, 25, 6, 46, 55, 0, ZoneId.systemDefault());
    strategy.exitSeconds = 60;

    assertEquals(expectedDatetime, strategy.getNextBusinessDay(ldt));
  }
/**
 * Base abstract class for entities which will hold definitions for created, last modified by and
 * created, last modified by date.
 */
public abstract class AbstractAuditingEntity implements Serializable {

  private static final long serialVersionUID = 1L;

  @CreatedBy
  @Field("created_by")
  @JsonIgnore
  private String createdBy;

  @CreatedDate
  @Field("created_date")
  @JsonIgnore
  private ZonedDateTime createdDate = ZonedDateTime.now();

  @LastModifiedBy
  @Field("last_modified_by")
  @JsonIgnore
  private String lastModifiedBy;

  @LastModifiedDate
  @Field("last_modified_date  ")
  @JsonIgnore
  private ZonedDateTime lastModifiedDate = ZonedDateTime.now();

  public String getCreatedBy() {
    return createdBy;
  }

  public void setCreatedBy(String createdBy) {
    this.createdBy = createdBy;
  }

  public ZonedDateTime getCreatedDate() {
    return createdDate;
  }

  public void setCreatedDate(ZonedDateTime createdDate) {
    this.createdDate = createdDate;
  }

  public String getLastModifiedBy() {
    return lastModifiedBy;
  }

  public void setLastModifiedBy(String lastModifiedBy) {
    this.lastModifiedBy = lastModifiedBy;
  }

  public ZonedDateTime getLastModifiedDate() {
    return lastModifiedDate;
  }

  public void setLastModifiedDate(ZonedDateTime lastModifiedDate) {
    this.lastModifiedDate = lastModifiedDate;
  }
}
Ejemplo n.º 15
0
 @Override
 public boolean isExpired(final TicketState ticketState) {
   if (ticketState == null) {
     return true;
   }
   final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
   final ZonedDateTime expirationTime =
       ticketState.getLastTimeUsed().plus(this.timeToKillInSeconds, ChronoUnit.SECONDS);
   return now.isAfter(expirationTime);
 }
Ejemplo n.º 16
0
 private static LocalDate parse(final DateTimeFormatter formatter, final String value) {
   try {
     Instant epoch = Instant.ofEpochMilli(Long.parseLong(value));
     ZonedDateTime zonedDate =
         epoch.atZone(Optional.ofNullable(formatter.getZone()).orElse(ZoneId.systemDefault()));
     return zonedDate.toLocalDate();
   } catch (NumberFormatException ex) {
     return LocalDate.parse(value, formatter);
   }
 }
 private static void verify_that_isNotIn_assertion_fails_and_throws_AssertionError(
     ZonedDateTime reference) {
   try {
     assertThat(reference).isNotIn(reference.toString(), reference.plusNanos(1).toString());
   } catch (AssertionError e) {
     // AssertionError was expected
     return;
   }
   fail("Should have thrown AssertionError");
 }
Ejemplo n.º 18
0
 /**
  * Not activated users should be automatically deleted after 3 days.
  *
  * <p>
  *
  * <p>This is scheduled to get fired everyday, at 01:00 (am).
  */
 @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);
   }
 }
Ejemplo n.º 19
0
  /**
   * Create a longterm forecast.
   *
   * @return A long term forecast, which is a week in our view of the world. But how many days you
   *     will get in this forecast depends on the given location forecast. So from 0-7 can be
   *     expected.
   */
  public MeteoExtrasLongTermForecast createLongTermForecast() {
    List<MeteoExtrasForecastDay> forecastDays = new ArrayList<>();
    ZonedDateTime dt = toZeroHMSN(getLocationForecast().getCreated().plusDays(1));

    for (int i = 0; i < series.getSeries().size(); i++) {
      createLongTermForecastDay(dt.plusDays(i), series.getSeries().get(i))
          .ifPresent(forecastDays::add);
    }

    return new MeteoExtrasLongTermForecast(forecastDays);
  }
 @Test
 public void isBeforeOrEqualTo_should_compare_datetimes_in_actual_timezone() {
   ZonedDateTime utcDateTime = ZonedDateTime.of(2013, 6, 10, 0, 0, 0, 0, ZoneOffset.UTC);
   ZoneId cestTimeZone = ZoneId.of("Europe/Berlin");
   ZonedDateTime cestDateTime1 = ZonedDateTime.of(2013, 6, 10, 2, 0, 0, 0, cestTimeZone);
   ZonedDateTime cestDateTime2 = ZonedDateTime.of(2013, 6, 10, 3, 0, 0, 0, cestTimeZone);
   // utcDateTime = cestDateTime1
   assertThat(utcDateTime).as("in UTC time zone").isBeforeOrEqualTo(cestDateTime1);
   //  utcDateTime < cestDateTime2
   assertThat(utcDateTime).as("in UTC time zone").isBeforeOrEqualTo(cestDateTime2);
 }
 @Test
 public void test_isIn_assertion_error_message() {
   try {
     assertThat(ZonedDateTime.of(2000, 1, 5, 3, 0, 5, 0, ZoneOffset.UTC))
         .isIn(ZonedDateTime.of(2012, 1, 1, 3, 3, 3, 0, ZoneOffset.UTC).toString());
   } catch (AssertionError e) {
     assertThat(e)
         .hasMessage(
             "\nExpecting:\n <2000-01-05T03:00:05.000Z>\nto be in:\n <[2012-01-01T03:03:03.000Z]>\n");
     return;
   }
   fail("Should have thrown AssertionError");
 }
 @Test
 public void test_isBeforeOrEqual_assertion_error_message() {
   try {
     assertThat(ZonedDateTime.of(2000, 1, 5, 3, 0, 5, 0, UTC))
         .isBeforeOrEqualTo(ZonedDateTime.of(1998, 1, 1, 3, 3, 3, 0, UTC));
   } catch (AssertionError e) {
     assertThat(e)
         .hasMessage(
             "\nExpecting:\n  <2000-01-05T03:00:05Z>\nto be before or equals to:\n  <1998-01-01T03:03:03Z>\n");
     return;
   }
   fail("Should have thrown AssertionError");
 }
Ejemplo n.º 23
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = super.hashCode();
   result = prime * result + ((_accrualEndDate == null) ? 0 : _accrualEndDate.hashCode());
   result = prime * result + ((_accrualStartDate == null) ? 0 : _accrualStartDate.hashCode());
   long temp;
   temp = Double.doubleToLongBits(_amount);
   result = prime * result + (int) (temp ^ (temp >>> 32));
   temp = Double.doubleToLongBits(_fixedRate);
   result = prime * result + (int) (temp ^ (temp >>> 32));
   return result;
 }
 @Theory
 public void test_isBeforeOrEqual_assertion(
     ZonedDateTime referenceDate, ZonedDateTime dateBefore, ZonedDateTime dateAfter) {
   // GIVEN
   testAssumptions(referenceDate, dateBefore, dateAfter);
   // WHEN
   assertThat(dateBefore).isBeforeOrEqualTo(referenceDate);
   assertThat(dateBefore).isBeforeOrEqualTo(referenceDate.toString());
   assertThat(referenceDate).isBeforeOrEqualTo(referenceDate);
   assertThat(referenceDate).isBeforeOrEqualTo(referenceDate.toString());
   // THEN
   verify_that_isBeforeOrEqual_assertion_fails_and_throws_AssertionError(dateAfter, referenceDate);
 }
Ejemplo n.º 25
0
 @Test
 public void testParseDateTime() {
   assertEquals(
       ZonedDateTime.of(1991, 12, 10, 12, 13, 14, 7000000, ZoneId.of("+01:00")),
       DateTimeUtils.parseDateTime("1991-12-10T12:13:14.007+01:00"));
   assertEquals(
       ZonedDateTime.of(1991, 12, 10, 12, 13, 14, 0, ZoneId.of("Z")),
       DateTimeUtils.parseDateTime("1991-12-10T12:13:14+00:00"));
   assertEquals(
       ZonedDateTime.of(1991, 12, 10, 12, 13, 14, 0, ZoneId.of("Z")),
       DateTimeUtils.parseDateTime("1991-12-10T12:13:14.000+00:00"));
   assertEquals(
       ZonedDateTime.of(1991, 12, 10, 12, 13, 14, 0, ZoneId.of("Z")),
       DateTimeUtils.parseDateTime("1991-12-10T12:13:14+0000"));
   assertEquals(
       ZonedDateTime.of(1991, 12, 10, 12, 13, 14, 0, ZoneId.of("Z")),
       DateTimeUtils.parseDateTime("1991-12-10T12:13:14.000+0000"));
   assertEquals(
       ZonedDateTime.of(1991, 12, 10, 12, 13, 14, 7000000, ZoneId.of("Z")),
       DateTimeUtils.parseDateTime("1991-12-10T12:13:14.007Z"));
   assertEquals(
       ZonedDateTime.of(1700, 1, 1, 1, 13, 14, 7000000, ZoneId.of("+00:19")),
       DateTimeUtils.parseDateTime("1700-01-01T01:13:14.007+00:19"));
   assertEquals(
       ZonedDateTime.of(1700, 2, 3, 2, 13, 14, 7000000, ZoneId.of("Z")),
       DateTimeUtils.parseDateTime("1700-02-03T02:13:14.007Z"));
 }
Ejemplo n.º 26
0
 /**
  * Create a longterm forecast, but only with a small subset of the weather data fields. Typically
  * for use in simple weather reports where you only show the predicted weather icon and
  * temperature, and not all the weather details.
  *
  * @return A long term forecast, which is a week in our view of the world.
  * @throws MeteoException If an error occurred while creating the simple longterm forecast.
  */
 public MeteoExtrasLongTermForecast createSimpleLongTermForecast() throws MeteoException {
   List<MeteoExtrasForecastDay> forecastDays = new ArrayList<>();
   ZonedDateTime dt = getNow();
   for (int i = 0; i <= 6; i++) {
     ZonedDateTime dti = dt.plusDays(i);
     if (getIndexer().hasForecastsForDay(dti)) {
       MeteoExtrasForecastDay mefd = createSimpleForcastForDay(dti);
       if (mefd != null && mefd.getForecasts().size() > 0) {
         forecastDays.add(mefd);
       }
     }
   }
   return new MeteoExtrasLongTermForecast(forecastDays);
 }
  private String[] setStandardTime(String requestUid, String time, User user) {

    final ZonedDateTime proposedDateTime;
    final String dateTimePrompt = getMessage(thisSection, "confirm", "time." + time, user);

    ZonedDateTime zonedNow = Instant.now().atZone(DateTimeUtil.getSAST());

    switch (time) {
      case "instant":
        proposedDateTime = zonedNow.plusMinutes(7L).truncatedTo(ChronoUnit.SECONDS);
        break;
      case "hour":
        proposedDateTime = zonedNow.plusHours(1L);
        break;
      case "day":
        proposedDateTime = zonedNow.plusDays(1L);
        break;
      case "week":
        proposedDateTime = zonedNow.plusWeeks(1L);
        break;
      default:
        // this should never be called, but need it else Java throws error -- defaulting to instant
        proposedDateTime = zonedNow.plusMinutes(7L);
        break;
    }

    eventRequestBroker.updateEventDateTime(
        user.getUid(), requestUid, proposedDateTime.toLocalDateTime());
    EventRequest voteRequest = eventRequestBroker.load(requestUid);
    return new String[] {voteRequest.getName(), dateTimePrompt};
  }
Ejemplo n.º 28
0
        @Override
        protected boolean matchesSafely(String item, Description mismatchDescription) {
            try {
                if (!date.isEqual(ZonedDateTime.parse(item))) {
                    mismatchDescription.appendText("was ").appendValue(item);
                    return false;
                }
                return true;
            } catch (DateTimeParseException e) {
                mismatchDescription.appendText("was ").appendValue(item)
                    .appendText(", which could not be parsed as a ZonedDateTime");
                return false;
            }

        }
Ejemplo n.º 29
0
  @Test
  public void shouldApplyBuiltInOnZonedDateTimeToCalendar() throws ParseException {
    assertThat(ZonedDateTimeToCalendarMapper.INSTANCE.map(null)).isNull();

    ZonedDateTimeProperty source = new ZonedDateTimeProperty();
    source.setProp(ZonedDateTime.of(1999, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
    source.publicProp = ZonedDateTime.of(2016, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault());

    CalendarProperty target = ZonedDateTimeToCalendarMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo(createCalendar("02.03.1999"));
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo(createCalendar("02.03.2016"));
  }
Ejemplo n.º 30
0
  private Optional<MeteoExtrasForecastDay> createLongTermForecastDay(
      ZonedDateTime dt, LongtermTimeSeries.LongtermTimeSerie serie) {
    if (!getIndexer().hasForecastsForDay(dt)) {
      return Optional.empty();
    }

    List<MeteoExtrasForecast> forecasts = new ArrayList<>();
    for (LongtermTimeSeries.FromTo fromTo : serie.getFromTos()) {
      getForecastForPeriod(dt.plusHours(fromTo.getFrom()), dt.plusHours(fromTo.getTo()))
          .ifPresent(forecasts::add);
    }
    return forecasts.size() > 0
        ? Optional.of(new MeteoExtrasForecastDay(dt.toLocalDate(), forecasts))
        : Optional.empty();
  }