Example usage for org.joda.time Interval getEndMillis

List of usage examples for org.joda.time Interval getEndMillis

Introduction

In this page you can find the example usage for org.joda.time Interval getEndMillis.

Prototype

public long getEndMillis() 

Source Link

Document

Gets the end of this time interval which is exclusive.

Usage

From source file:de.fraunhofer.iosb.ilt.sta.persistence.postgres.PgExpressionHandler.java

License:Open Source License

@Override
public Expression<?> visit(IntervalConstant node) {
    Interval value = node.getValue();
    return new TimeIntervalExpression(
            new ConstantDateTimeExpression(new Timestamp(value.getStartMillis()), true),
            new ConstantDateTimeExpression(new Timestamp(value.getEndMillis()), true));
}

From source file:de.hpi.bpmn2_0.replay.TimeUtilities.java

License:Open Source License

public static ArrayList<Interval> divide(Interval v1, Interval v2) {
    ArrayList<Interval> divide = new ArrayList();
    Interval overlap = v1.overlap(v2);

    if (overlap != null) {
        long overlapStart = overlap.getStartMillis();
        long overlapEnd = overlap.getEndMillis();

        long v1Start = v1.getStartMillis();
        long v1End = v1.getEndMillis();

        long v2Start = v2.getStartMillis();
        long v2End = v2.getEndMillis();

        long minStart = Math.min(v1Start, v2Start);
        long maxEnd = Math.max(v1End, v2End);

        divide.add(new Interval(minStart, overlapStart));
        divide.add(overlap);/*w ww. ja  v  a 2 s .c  o  m*/
        divide.add(new Interval(overlapEnd, maxEnd));
    }
    return divide;
}

From source file:de.javakaffee.kryoserializers.jodatime.JodaIntervalSerializer.java

License:Apache License

@Override
public void write(final Kryo kryo, final Output output, final Interval obj) {
    final long startMillis = obj.getStartMillis();
    final long endMillis = obj.getEndMillis();
    final String chronologyId = IdentifiableChronology.getChronologyId(obj.getChronology());

    output.writeLong(startMillis, true);
    output.writeLong(endMillis, true);//ww  w . j ava 2s. c  o  m
    output.writeString(chronologyId == null ? "" : chronologyId);
}

From source file:dk.dma.ais.store.AisStoreQueryBuilder.java

License:Apache License

public AisStoreQueryBuilder setInterval(Interval interval) {
    return setInterval(Instant.ofEpochMilli(interval.getStartMillis()),
            Instant.ofEpochMilli(interval.getEndMillis()));
}

From source file:io.coala.dsol.util.DsolAccumulator.java

License:Apache License

/** helper method */
protected void updateValue() {
    final DateTime changeTime = getDateTime();
    if (!changeTime.isAfter(this.lastChangeTime))
        return;/* ww w. ja va  2  s. c o m*/
    final Interval interval = DsolUtil.crop(new Interval(this.lastChangeTime, changeTime), getTreatment());
    if (interval.getEndMillis() != changeTime.getMillis())
        LOG.warn(String.format("Cropped interval end time %s to %s", changeTime, interval));
    this.lastChangeTime = changeTime;

    final double oldRate = getRate().doubleValue();
    double deltaRate = oldRate;
    if (this.integrateMin != null && this.integrateMin.doubleValue() > deltaRate) {
        // LOG.trace("Integrating " + getRateTitle() + " with minimum "
        // + this.integrateMin);
        deltaRate = this.integrateMin.doubleValue();
    } else if (this.integrateMax != null && deltaRate > this.integrateMax.doubleValue()) {
        // LOG.trace("Integrating " + getRateTitle() + " with maximum "
        // + this.integrateMax);
        deltaRate = this.integrateMax.doubleValue();
    }
    final double deltaValue = DsolUtil
            .toTimeUnit(this.timeUnit, deltaRate * interval.toDurationMillis(), TimeUnitInterface.MILLISECOND)
            .doubleValue();
    addValue(deltaValue);
}

From source file:io.coala.dsol.util.DsolUtil.java

License:Apache License

/**
 * @return overlap of specified interval within replication run period
 *         (after warm-up and before run length)
 *///from w  w  w . j a v a2s .  c  om
public static Interval crop(final Interval interval, final Treatment treatment) {
    final Interval runPeriod = getRunInterval(treatment);
    if (interval.overlaps(runPeriod)) {
        final long croppedStart = Math.max(interval.getStartMillis(), runPeriod.getStartMillis());
        final long croppedEnd = Math.min(interval.getEndMillis(), runPeriod.getEndMillis());
        return new Interval(croppedStart, croppedEnd);
    }
    return interval;
}

From source file:io.druid.benchmark.datagen.BenchmarkDataGenerator.java

License:Apache License

public BenchmarkDataGenerator(List<BenchmarkColumnSchema> columnSchemas, final long seed, Interval interval,
        int numRows) {
    this.columnSchemas = columnSchemas;
    this.seed = seed;

    this.startTime = interval.getStartMillis();
    this.endTime = interval.getEndMillis() - 1;

    Preconditions.checkArgument(endTime >= startTime, "endTime >= startTime");

    long timeDelta = endTime - startTime;
    this.timestampIncrement = timeDelta / (numRows * 1.0);
    this.numConsecutiveTimestamps = 0;

    init();//from   w  ww.  ja  va2 s. com
}

From source file:io.druid.client.CacheUtil.java

License:Apache License

public static Cache.NamedKey computeSegmentCacheKey(String segmentIdentifier, SegmentDescriptor descriptor,
        byte[] queryCacheKey) {
    final Interval segmentQueryInterval = descriptor.getInterval();
    final byte[] versionBytes = com.metamx.common.StringUtils.toUtf8(descriptor.getVersion());

    return new Cache.NamedKey(segmentIdentifier,
            ByteBuffer.allocate(16 + versionBytes.length + 4 + queryCacheKey.length)
                    .putLong(segmentQueryInterval.getStartMillis()).putLong(segmentQueryInterval.getEndMillis())
                    .put(versionBytes).putInt(descriptor.getPartitionNumber()).put(queryCacheKey).array());
}

From source file:io.druid.query.aggregation.atomcube.AtomCubeQuery.java

License:Apache License

private Cache.NamedKey getKey(Query _query) {
    Cache.NamedKey key = null;//from w w  w. jav a  2  s  .  c  o  m
    StringBuffer sb = new StringBuffer();
    List<String> dsNames = _query.getDataSource().getNames();
    Collections.sort(dsNames, Ordering.natural());
    for (String s : dsNames) {
        sb.append(s);
    }
    List<Interval> intervals = _query.getIntervals();
    for (Interval interval : sortIntervals(intervals)) {
        long start = interval.getStartMillis();
        long end = interval.getEndMillis();
        sb.append(start).append(end);
    }
    byte[] filterKey = new byte[0];
    if (_query.hasFilters()) {
        if (_query instanceof TimeseriesQuery) {
            TimeseriesQuery query = (TimeseriesQuery) _query;
            filterKey = query.getDimensionsFilter().getCacheKey();
        } else if (_query instanceof TopNQuery) {
            TopNQuery query = (TopNQuery) _query;
            filterKey = query.getDimensionsFilter().getCacheKey();

        } else if (_query instanceof GroupByQuery) {
            GroupByQuery query = (GroupByQuery) _query;
            filterKey = query.getDimFilter().getCacheKey();
        }
    }
    String queryId = Integer.toHexString(sb.toString().hashCode());
    key = new Cache.NamedKey(queryId, ByteBuffer.allocate(queryId.getBytes().length + filterKey.length)
            .put(queryId.getBytes()).put(filterKey).array());
    return key;
}

From source file:io.druid.query.filter.IntervalDimFilter.java

License:Apache License

private List<Pair<Long, Long>> makeIntervalLongs() {
    List<Pair<Long, Long>> intervalLongs = new ArrayList<>();
    for (Interval interval : intervals) {
        intervalLongs.add(new Pair<Long, Long>(interval.getStartMillis(), interval.getEndMillis()));
    }//from  w w w .j a  v  a  2  s.c om
    return intervalLongs;
}