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: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();/*w  ww. java2  s.c o 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.twitter.pipeline.MySQLTweetChronologicalProducer.java

License:Apache License

private void parameteriseGetDataStatement(Interval interval) throws SQLException {
    ensureConnectionOpen();/*from   w  w w . j av  a2s  .  c o m*/
    getDataStatement.setLong(1, interval.getStartMillis() / 1000);
    getDataStatement.setLong(2, interval.getEndMillis() / 1000);
}

From source file:uk.ac.susx.tag.method51.twitter.pipeline.TweetGenerator.java

License:Apache License

@Override
protected void doWork() throws Exception {

    Interval interval = getService().getNextInterval();
    Interval lifetime = getService().getLifetime();

    final long taskTime = interval.getEndMillis();
    final long taskStartTime = lifetime.getStartMillis();
    final long taskEndTime = lifetime.getEndMillis();
    final long taskDuration = lifetime.toDurationMillis();

    if (taskTime >= taskEndTime) {
        stopAsync();/* www . j  av a2s  . c  om*/
        return;
    }

    List<Tweet> tweets = new LinkedList<>();
    int intervalTotal;
    switch (shape) {
    case FLAT:
        intervalTotal = rate;
        break;
    case SINE_WAVE:
        double progress = (taskTime - taskStartTime) / (double) taskDuration;
        intervalTotal = (int) Math.floor(rate * Math.sin(progress * Math.PI));
        break;
    default:
        intervalTotal = rate;
        break;
    }

    for (int i = 0; i < intervalTotal; ++i) {
        tweets.add(generateTweet(i, intervalTotal));
    }

    produce(tweets);

}