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};
  }
 // -------------------------------------------------------------------------
 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);
 }
  private void createBloodPressureByMonth(
      ZonedDateTime firstOfMonth, ZonedDateTime firstDayOfLastMonth) {
    User user = userRepository.findOneByLogin("user").get();
    // this month
    bloodPressure = new BloodPressure(firstOfMonth, 120, 80, user);
    bloodPressureRepository.saveAndFlush(bloodPressure);
    bloodPressure = new BloodPressure(firstOfMonth.plusDays(10), 125, 75, user);
    bloodPressureRepository.saveAndFlush(bloodPressure);
    bloodPressure = new BloodPressure(firstOfMonth.plusDays(20), 100, 69, user);
    bloodPressureRepository.saveAndFlush(bloodPressure);

    // last month
    bloodPressure = new BloodPressure(firstDayOfLastMonth, 130, 90, user);
    bloodPressureRepository.saveAndFlush(bloodPressure);
    bloodPressure = new BloodPressure(firstDayOfLastMonth.plusDays(11), 135, 85, user);
    bloodPressureRepository.saveAndFlush(bloodPressure);
    bloodPressure = new BloodPressure(firstDayOfLastMonth.plusDays(23), 130, 75, user);
    bloodPressureRepository.saveAndFlush(bloodPressure);
  }
예제 #4
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
 /** Tests the toDerivative method when the reference date is after the premium settlement. */
 public void toDerivativeAfterSettlement() {
   final ZonedDateTime referenceDate = PREMIUM_DATE.plusDays(1);
   final InterestRateFutureOptionPremiumTransaction transactionConverted =
       OPTION_TRANSACTION.toDerivative(referenceDate);
   final InterestRateFutureOptionPremiumSecurity security =
       OPTION_EDU2.toDerivative(referenceDate);
   final double premiumTime = 0.0;
   final double price = 0.0; // The payment is in the past and is represented by a 0 payment today.
   final InterestRateFutureOptionPremiumTransaction transaction =
       new InterestRateFutureOptionPremiumTransaction(security, QUANTITY, premiumTime, price);
   assertEquals("Option on future: to derivative", transaction, transactionConverted);
 }
예제 #6
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 List<SearchRequestBuilder> makeRequestBuilders() {
   List<SearchRequestBuilder> builders = new ArrayList<>();
   ZonedDateTime currentDate = config.getFrom();
   ZonedDateTime maxDate = up(TimeUnit.HOURS, config.getTo());
   do {
     builders.add(
         client
             .prepareSearch(
                 appendForEach(INDEXES_PREFIXES, ELASTIC_INDEX_DATE_FORMAT.format(currentDate)))
             .setTypes(TYPES)
             .setSize(config.getBucketSize())
             .setPostFilter(FilterBuilders.andFilter(makeFilters(currentDate))));
     currentDate = currentDate.plusDays(1);
   } while (currentDate.isBefore(maxDate));
   return builders;
 }
  private void addSomeRecords(String ric, String name, String expiry, OptionType type) {

    si = new SimpleSecurityIdentifier(IdentifierScheme.RIC, ric);
    OptionContractImpl option;

    // Add some representative end of day records.
    final ZonedDateTime monthAgo = getOneMonthAgo();
    for (int i = 0; i < 28; i++) {
      option = new OptionContractImpl(si, monthAgo.plusDays(i), type, expiry, 25.5D, name);
      endOfDayRecords.add(option);
    }

    // Add some representative intra-day records.
    final ZonedDateTime dayAgo = getOneDayAgo();
    for (int i = 0; i < 20; i++) {
      option = new OptionContractImpl(si, dayAgo.plusHours(i), type, expiry, 25.5D, name);
      intraDayRecords.add(option);
    }
  }
  @Test
  public void testTimeStamp() {
    ZonedDateTime dt = ZonedDateTime.of(2015, 11, 9, 12, 0, 0, 0, ZoneId.systemDefault());

    Comment c = new Comment();
    c.setBody(new String[0]);

    c.setTimeStamp(dt.plusDays(0).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("MONDAY"));
    c.setTimeStamp(dt.plusDays(1).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("TUESDAY"));
    c.setTimeStamp(dt.plusDays(2).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("WEDNESDAY"));
    c.setTimeStamp(dt.plusDays(3).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("THURSDAY"));
    c.setTimeStamp(dt.plusDays(4).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("FRIDAY"));
    c.setTimeStamp(dt.plusDays(5).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("SATURDAY"));
    c.setTimeStamp(dt.plusDays(6).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("SUNDAY"));
    c.setTimeStamp(dt.plusDays(7).toInstant().getEpochSecond());
    assertThat(toDayOfWeek(AnalysedComment.of(c, 0.0).getDateTime()), equalTo("MONDAY"));
  }