Implement methods for duration of a trip.

This commit is contained in:
Andreas Schildbach 2015-02-02 10:11:19 +01:00
parent d00e107fdf
commit e86fdede13

View file

@ -113,6 +113,25 @@ public final class Trip implements Serializable
return null;
}
/** Duration of whole trip in milliseconds, including leading and trailing individual legs. */
public long getDuration()
{
final Date first = getFirstDepartureTime();
final Date last = getLastArrivalTime();
return last.getTime() - first.getTime();
}
/**
* Duration of the public leg part in milliseconds. This includes individual legs between public legs, but excludes
* individual legs that lead or trail the trip.
*/
public long getPublicDuration()
{
final Date first = getFirstPublicLegDepartureTime();
final Date last = getLastPublicLegArrivalTime();
return last.getTime() - first.getTime();
}
/** Minimum time occuring in this trip. */
public Date getMinTime()
{