Example usage for org.joda.time Duration Duration

List of usage examples for org.joda.time Duration Duration

Introduction

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

Prototype

public Duration(ReadableInstant start, ReadableInstant end) 

Source Link

Document

Creates a duration from the given interval endpoints.

Usage

From source file:io.vitess.client.Context.java

License:Apache License

@Nullable
public Duration getTimeout() {
    if (deadline == null) {
        return null;
    }//from w w w .j  a  v a2  s.  c o m
    return new Duration(null, deadline);
}

From source file:is.illuminati.block.spyros.garmin.model.Activity.java

License:Open Source License

/**
 * Get gross duration (from start time to time of last measurement) of the
 * Activity.//from  w ww .jav a2 s. co m
 * @return gross duration
 */
public Duration getGrossDuration() {
    return new Duration(startTime, getLastTrackPoint().getTime());
}

From source file:is.illuminati.block.spyros.garmin.model.Activity.java

License:Open Source License

/**
 * Get net duration (from start time to time of last measurement, minus
 * pauses) of the {@link Activity}./*from   w ww  . j  a  v a  2s. c  om*/
 * @return net duration
 */
public Duration getNetDuration() {
    // start with the difference between start time and first lap start time.
    Duration netDuration = new Duration(startTime, laps.get(0).getStartTime());
    for (Lap lap : laps) {
        netDuration = netDuration.plus(lap.getNetDuration());
    }
    return netDuration;
}

From source file:is.illuminati.block.spyros.garmin.model.Lap.java

License:Open Source License

/**
 * Get a list of all pauses in the lap.// w  w  w.  ja va2s .co  m
 * @return list of all pauses.
 */
public ImmutableList<Pause> getPauses() {
    ImmutableList.Builder<Pause> pausesBuilder = ImmutableList.builder();
    PeekingIterator<Track> it = Iterators.peekingIterator(tracks.iterator());
    while (it.hasNext()) {
        Track former = it.next();
        Track latter;
        if (it.hasNext()) {
            latter = it.peek();
        } else {
            break;
        }
        Duration gap = new Duration(former.getEndTime(), latter.getStartTime());
        if (gap.isLongerThan(Duration.standardSeconds(10))) {
            pausesBuilder.add(new Pause(former.getEndTime(), latter.getStartTime()));
        }
    }
    return pausesBuilder.build();
}

From source file:is.illuminati.block.spyros.garmin.model.Lap.java

License:Open Source License

/**
 * Get gross duration of Lap. That is, the total time from start of the lap 
 * to the end./*  ww w. ja  va 2  s  .c  o  m*/
 * @return gross duration of the lap
 */
public Duration getGrossDuration() {
    return new Duration(getStartTime(), getEndTime());
}

From source file:is.illuminati.block.spyros.garmin.model.Lap.java

License:Open Source License

/**
 * Get net duration of Lap. That is, the time from start to end, minus the
 * pauses.//from  w w w . j a v a2 s . c  o m
 * @return net duration of lap.
 */
public Duration getNetDuration() {
    Duration duration = new Duration(startTime, tracks.get(0).getStartTime());
    for (Track track : tracks) {
        duration = duration.plus(track.getDuration());
    }
    return duration;
}

From source file:is.illuminati.block.spyros.garmin.model.NonStartTrackPoint.java

License:Open Source License

/**
 * {@inheritDoc}//from   w w w.j  a va2s.co  m
 */
@Override
public Speed getSpeed() {
    Length distanceTravelled = getDistance().substract(previousTrackPoint.getDistance());
    Duration timeTravelled = new Duration(previousTrackPoint.getTime(), getTime());

    return Speed.createSpeedInMetersPerSecond(distanceTravelled, timeTravelled);
}

From source file:is.illuminati.block.spyros.garmin.model.StartTrackPoint.java

License:Open Source License

/**
 * {@inheritDoc}/*w  w  w  .  ja  va2 s .  c o m*/
 */
@Override
public Speed getSpeed() {
    final Duration timeTravelled = new Duration(startTime, getTime());
    return Speed.createSpeedInMetersPerSecond(getDistance(), timeTravelled);
}

From source file:is.illuminati.block.spyros.garmin.model.Track.java

License:Open Source License

/**
 * Get duration of track.
 * @return the duration
 */
public Duration getDuration() {
    return new Duration(getStartTime(), getEndTime());
}

From source file:it.tidalwave.actor.CollaborationCompletedMessage.java

License:Apache License

/*******************************************************************************************************************
 *
 * Returns the time this {@link Collaboration} took to complete.
 *
 * @return    the duration/*from  www .  j  av a2 s.c o m*/
 *
 ******************************************************************************************************************/
@Nonnull
public Duration getDuration() {
    return new Duration(getStartTime().getMillis(), endTime);
}