Package org.threeten.bp

Examples of org.threeten.bp.Duration


    final int factorType = arg0.getFactorType().getFactorType().compareTo(arg1.getFactorType().getFactorType());
    if (factorType != 0) {
      return factorType;
    }
    if (arg0.getNode() != null && arg0.getNode().length() > 0) {
      Duration p0 = Duration.parse("P" + arg0.getNode());
      if (arg1.getNode() != null && arg1.getNode().length() > 0) {
        Duration p1 = Duration.parse("P" + arg1.getNode());
        final long node = p0.toNanos() - p1.toNanos();
        if (node != 0) {
          return (int) node;
        }
      } else {
        return 1;
View Full Code Here


   * @param corrInstant  the correction instant, not null
   * @return the unique identifier
   */
  protected UniqueId createTimeSeriesUniqueId(long oid, Instant verInstant, Instant corrInstant) {
    String oidStr = DATA_POINT_PREFIX + oid;
    Duration dur = Duration.between(verInstant, corrInstant);
    String verStr = verInstant.toString() + dur.toString();
    return UniqueId.of(getUniqueIdScheme(), oidStr, verStr);
  }
View Full Code Here

  //-------------------------------------------------------------------------
  //TODO [PLAT-1013] not the best way to do this
  @Override
  public int compareTo(Tenor other) {
    Duration thisDur = DateUtils.estimatedDuration(this._period);
    Duration otherDur = DateUtils.estimatedDuration(other._period);
    return thisDur.compareTo(otherDur);
  }
View Full Code Here

      ++i;
    }

    final ZonedDateTime stop = ZonedDateTime.now();
    final Duration elapsedTime = Duration.between(start, stop);
    final double seconds = elapsedTime.getSeconds() + (elapsedTime.getNano() / 1000000) / 1000.0;

    s_logger.debug( "Executed " + i + " test cases in " + seconds + "s with " + failures + " failure(s)"
      + (considerRelativeErrorForFailures ? " and " + marginalCases + " marginal case(s)" : "")
      + ", largest dirty absolute error was " + maxAbsoluteError
      + ", largest dirty relative error was " + maxRelativeError
View Full Code Here

  @Override
  public void start() {
    LocalDateTime now = LocalDateTime.now();
    LocalDateTime nextHour = now.truncatedTo(HOURS).plusHours(1);
    Duration delay = Duration.between(now.atOffset(ZoneOffset.UTC), nextHour.atOffset(ZoneOffset.UTC));
    Duration oneHour = Duration.ofHours(1);
    s_logger.warn("Now {} Next {} Delay {} {}", new Object[] {now, nextHour, delay, delay.toMillis() });
    _timerExecutor.scheduleAtFixedRate(new SnapshotTask(), delay.toMillis(), oneHour.toMillis(), TimeUnit.MILLISECONDS);
    if (getInitializationFileName() != null) {
      initializeFromFile(getInitializationFileName());
    }
  }
View Full Code Here

   *
   * @param period the period to estimate the duration of, not null
   * @return the estimated duration, not null
   */
  public static Duration estimatedDuration(Period period) {
    Duration monthsDuration = MONTHS.getDuration().multipliedBy(period.toTotalMonths());
    Duration daysDuration = DAYS.getDuration().multipliedBy(period.getDays());
    return monthsDuration.plus(daysDuration);
  }
View Full Code Here

    // Assume that valuation times are increasing in real-time towards the expiry of the view definition, so that we
    // can predict the time to expiry. If this assumption is wrong then the worst we do is trigger an unnecessary
    // cycle. In the predicted case, we trigger a cycle on expiry so that any new market data subscriptions are made
    // straight away.
    if ((compiledViewDefinition.getValidTo() != null) && getExecutionOptions().getFlags().contains(ViewExecutionFlags.TRIGGER_CYCLE_ON_MARKET_DATA_CHANGED)) {
      final Duration durationToExpiry = _marketDataManager.getMarketDataProvider().getRealTimeDuration(valuationTime,
          compiledViewDefinition.getValidTo());
      final long expiryNanos = System.nanoTime() + durationToExpiry.toNanos();
      _compilationExpiryCycleTrigger.set(expiryNanos, ViewCycleTriggerResult.forceFull());
      // REVIEW Andrew 2012-11-02 -- If we are ticking live, then this is almost right (System.nanoTime will be close to valuationTime, depending on how
      // long the compilation took). If we are running through historical data then this is quite a meaningless trigger.
    } else {
      _compilationExpiryCycleTrigger.reset();
View Full Code Here

    final UniqueId viewProcessId = message.getValue(UniqueId.class, FIELD_VIEWPROCESSID);
    final UniqueId viewCycleId = message.getValue(UniqueId.class, FIELD_VIEWCYCLEID);
    final ViewCycleExecutionOptions viewCycleExecutionOptions = deserializer.fieldValueToObject(ViewCycleExecutionOptions.class, message.getByName(FIELD_VIEW_CYCLE_EXECUTION_OPTIONS));
    final Instant calculationTime = message.getFieldValue(Instant.class, message.getByName(FIELD_CALCULATION_TIME));
    FudgeField durationField = message.getByName(FIELD_CALCULATION_DURATION);
    final Duration calculationDuration = durationField != null ? deserializer.fieldValueToObject(Duration.class, durationField) : null;
    final VersionCorrection versionCorrection = deserializer.fieldValueToObject(VersionCorrection.class, message.getByName(FIELD_VERSION_CORRECTION));
    final Map<String, ViewCalculationResultModel> configurationMap = new HashMap<String, ViewCalculationResultModel>();
    final Queue<String> keys = new LinkedList<String>();
    final Queue<ViewCalculationResultModel> values = new LinkedList<ViewCalculationResultModel>();
    for (FudgeField field : message.getFieldValue(FudgeMsg.class, message.getByName(FIELD_RESULTS))) {
View Full Code Here

  @Override
  public void init(Set<ValueSpecification> values, long timeout, TimeUnit ucUnit) {
    Instant start = OpenGammaClock.getInstance().instant();
    TemporalUnit unit = convertUnit(ucUnit);
    Duration remaining = Duration.of(timeout, unit);

    _historicalSnapshot1.init(values, timeout, ucUnit);
    Instant after1 = OpenGammaClock.getInstance().instant();
    Duration duration1 = Duration.between(start, after1);
    remaining = remaining.minus(duration1);
    if (remaining.isNegative()) {
      return;
    }
    _historicalSnapshot2.init(values, remaining.get(unit), ucUnit);
    Instant after2 = OpenGammaClock.getInstance().instant();
    Duration duration2 = Duration.between(after1, after2);
    remaining = remaining.minus(duration2);
    if (remaining.isNegative()) {
      return;
    }
    _baseSnapshot.init(values, remaining.get(unit), ucUnit);
View Full Code Here

TOP

Related Classes of org.threeten.bp.Duration

Copyright © 2018 www.massapicom. 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.