Example usage for org.joda.time Interval contains

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

Introduction

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

Prototype

public boolean contains(long millisInstant) 

Source Link

Document

Does this time interval contain the specified millisecond instant.

Usage

From source file:syncthing.android.service.ServiceSettings.java

License:Open Source License

long getNextScheduledEndTime() {
    long start = SyncthingUtils.parseTime(getScheduledStartTime());
    long end = SyncthingUtils.parseTime(getScheduledEndTime());
    DateTime now = DateTime.now();//from  ww w  .j av  a 2 s  .  co m
    Interval interval = SyncthingUtils.getIntervalForRange(now, start, end);
    if (interval.contains(now)) {
        //With scheduled range
        return interval.getEndMillis();
    } else {
        //Outside scheduled range, shutdown asap
        return now.getMillis() + AlarmManagerHelper.KEEP_ALIVE;
    }
}

From source file:uk.ac.susx.tag.method51.core.pipeline.examples.DateTimeProducer.java

License:Apache License

@Override
protected void doWork() throws Exception {

    Interval iterationInterval = getChronologicalService().getNextInterval();

    if (LOG.isDebugEnabled())
        LOG.debug("Producing for interval: {}", iterationInterval);

    ImmutableList.Builder<DateTime> batch = ImmutableList.builder();

    for (DateTime dateTime : elements) {
        if (iterationInterval.contains(dateTime)) {
            batch.add(dateTime);//from www . j av  a 2 s .  c o  m
        }
    }

    produce(batch.build());

    if (getChronologicalService().hasEnded()) {
        stopAsync();
    }
}

From source file:wad.domain.resource.Resource.java

public boolean isAvailable(Interval interval) {
    Interval floorReserveableInterval = this.reservableIntervals.floor(interval);
    if (floorReserveableInterval == null || !floorReserveableInterval.contains(interval)) {
        return false;
    }/*w ww .j a  v  a 2  s .  co m*/
    Interval floorReservedInterval = this.reservableIntervals.floor(interval);
    if (floorReservedInterval != null && floorReservedInterval.overlaps(interval)) {
        return false;
    }
    Interval ceilingReservedInterval = this.reservableIntervals.ceiling(interval);
    if (ceilingReservedInterval != null && ceilingReservedInterval.overlaps(interval)) {
        return false;
    }
    return true;
}