Examples of ZoneId


Examples of org.threeten.bp.ZoneId

    try {
      time = LocalTime.from(temporal);
    } catch (Exception ex) {
      time = null;
    }
    ZoneId zone = temporal.query(TemporalQueries.zone());
    return new FlexiDateTime(date, time, zone);
  }
View Full Code Here

Examples of org.threeten.bp.ZoneId

      return ImmutableLocalDateDoubleTimeSeries.of(dates, values);
    }
   
    // read old ZonedDateTimeDoubleTimeSeries, see OpenGammaFudgeContext
    if (message.getByOrdinal(0).toString().contains("ZonedDateTimeDoubleTimeSeries")) {
      ZoneId zone = ZoneOffset.UTC;
      try {
        FudgeMsg converter = message.getMessage(1);
        zone = ZoneId.of(converter.getString(1));
      } catch (RuntimeException ex) {
        // ignore
      }
      FudgeMsg fastSeries = message.getMessage(2);
      String encoding = fastSeries.getMessage(1).getString(1);
      long[] instants = (long[]) fastSeries.getValue(2);
      double[] values = (double[]) fastSeries.getValue(3);
      if (encoding.equals("TIME_EPOCH_NANOS")) {  // CSIGNORE
        // correct encoding
      } else if (encoding.equals("TIME_EPOCH_MILLIS")) {
        for (int i = 0; i < instants.length; i++) {
          instants[i] = instants[i] * 1_000_000;
        }
      } else if (encoding.equals("TIME_EPOCH_SECONDS")) {
        for (int i = 0; i < instants.length; i++) {
          instants[i] = instants[i] * 1_000_000_000;
        }
      } else {
        throw new IllegalArgumentException("Unknown time-series encoding");
      }
      return ImmutableZonedDateTimeDoubleTimeSeries.of(instants, values, zone);
    }
   
    // read new format
    int[] dates = (int[]) message.getValue(DATES);
    long[] instants = (long[]) message.getValue(INSTANTS);
    double[] values = (double[]) message.getValue(VALUES);
    String zoneId = message.getString(ZONE);
    if (dates != null) {
      return ImmutableLocalDateDoubleTimeSeries.of(dates, values);
    }
    if (instants != null) {
      if (zoneId != null) {
        ZoneId zone = ZoneId.of(zoneId);
        return ImmutableZonedDateTimeDoubleTimeSeries.of(instants, values, zone);
      } else {
        return ImmutableInstantDoubleTimeSeries.of(instants, values);
      }
    }
View Full Code Here

Examples of org.threeten.bp.ZoneId

    if (regionId == null) {
      throw new OpenGammaRuntimeException("Could not find region for " + security.getIssuerDomicile());
    }
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, regionId);
    final Currency currency = security.getCurrency();
    final ZoneId zone = security.getInterestAccrualDate().getZone();
    final ZonedDateTime firstAccrualDate = ZonedDateTime.of(security.getInterestAccrualDate().toLocalDate().atStartOfDay(), zone);
    final ZonedDateTime maturityDate = ZonedDateTime.of(security.getLastTradeDate().getExpiry().toLocalDate().atStartOfDay(), zone);
    final double rate = security.getCouponRate() / 100;
    final DayCount dayCount = security.getDayCount();
    final BusinessDayConvention businessDay = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
View Full Code Here

Examples of org.threeten.bp.ZoneId

    if (!isValidField(fieldData.getString(fieldName))) {
      return null;
    }
    // These will need to be sorted out.
    LocalTime expiryTime = LocalTime.of(17, 00);
    ZoneId zone = ZoneOffset.UTC;
    LocalDate localDate = LocalDate.parse(fieldData.getString(fieldName));
    return localDate.atTime(expiryTime).atZone(zone);
  }
View Full Code Here

Examples of org.threeten.bp.ZoneId

      }
      String guaranteeType = fieldData.getString(FIELD_GUARANTOR); // bit unsure about this one.
      String maturityStr = validateAndGetStringField(fieldData, FIELD_MATURITY);
      // These will need to be sorted out.
      LocalTime expiryTime = LocalTime.of(17, 00);
      ZoneId zone = ZoneOffset.UTC;
      Expiry maturity = null;
      try {
        maturity = new Expiry(LocalDate.parse(maturityStr).atTime(expiryTime).atZone(zone), ExpiryAccuracy.DAY_MONTH_YEAR);
      } catch (Exception e) {
        throw new OpenGammaRuntimeException(maturityStr + " returned from bloomberg not in format yyyy-mm-dd", e);
View Full Code Here

Examples of org.threeten.bp.ZoneId

   * Time between dates in different time zones, when one is near midnight.
   * Trouble arises because timeBetween(date1,date2) != -1 * timeBetween(date2,date1).
   * TimeCalculator computes time in ACTACT Daycount convention, hence fractions of a day are rounded to either 0 or 1 day's year fraction..
   */
  public void plat4725() {
    ZoneId gmt = ZoneId.of("GMT");
    ZoneId london = ZoneId.of("+01:00");

    final ZonedDateTime date1 = ZonedDateTime.of(2013, 9, 24, 0, 0, 1, 0, london);
    final ZonedDateTime date2 = ZonedDateTime.of(2013, 9, 24, 9, 2, 45,936, gmt);
    final double time12 = TimeCalculator.getTimeBetween(date1, date2);
    final double time21 = TimeCalculator.getTimeBetween(date2, date1);
View Full Code Here

Examples of org.threeten.bp.ZoneId

  private final LocalDate referenceDate = LocalDate.of(2010, 4, 23);
  private final LocalDate nowDate = LocalDate.of(2013, 3, 5);

  private FunctionExecutionContext mockExecutionContext() {
    final FunctionExecutionContext context = new FunctionExecutionContext();
    final ZoneId zone = ZoneId.of("UTC");
    context.setValuationClock(Clock.fixed(nowDate.atStartOfDay(zone).toInstant(), zone));
    return context;
  }
View Full Code Here

Examples of org.threeten.bp.ZoneId

   *
   * @param calendar the calendar, not null
   * @return the zoned-date-time, not null
   */
  public static ZonedDateTime toZonedDateTime(GregorianCalendar calendar) {
    ZoneId zone = ZoneId.of(calendar.getTimeZone().getID());
    Instant instant = Instant.ofEpochMilli(calendar.getTimeInMillis());
    return ZonedDateTime.ofInstant(instant, zone);
  }
View Full Code Here

Examples of org.threeten.bp.ZoneId

  public static ZonedDateTime fromFudgeMsg(final FudgeDeserializer deserializer, final FudgeMsg msg) {
    if (msg == null) {
      return null;
    }
    final OffsetDateTime odt = msg.getValue(OffsetDateTime.class, DATETIME_FIELD_NAME);
    final ZoneId zone = msg.getValue(ZoneId.class, ZONE_FIELD_NAME);
    return odt.atZoneSameInstant(zone);
  }
View Full Code Here

Examples of org.threeten.bp.ZoneId

  public static void toFudgeMsg(final FudgeSerializer serializer, final FlexiDateTime object, final MutableFudgeMsg msg) {
    Temporal best = object.toBest();
    best = (best instanceof ZonedDateTime ? ((ZonedDateTime) best).toOffsetDateTime() : best);
    addToMessage(msg, DATETIME_FIELD_NAME, best);
    ZoneId zone = object.getZone();
    if (zone != null && zone instanceof ZoneOffset == false) {
      addToMessage(msg, ZONE_FIELD_NAME, zone);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.