mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 00:39:58 +00:00
Method for public duration of a trip can return null.
This commit is contained in:
parent
76458296a0
commit
24e921e547
1 changed files with 12 additions and 3 deletions
|
@ -113,7 +113,11 @@ public final class Trip implements Serializable
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Duration of whole trip in milliseconds, including leading and trailing individual legs. */
|
/**
|
||||||
|
* Duration of whole trip in milliseconds, including leading and trailing individual legs.
|
||||||
|
*
|
||||||
|
* @return duration in ms
|
||||||
|
*/
|
||||||
public long getDuration()
|
public long getDuration()
|
||||||
{
|
{
|
||||||
final Date first = getFirstDepartureTime();
|
final Date first = getFirstDepartureTime();
|
||||||
|
@ -124,12 +128,17 @@ public final class Trip implements Serializable
|
||||||
/**
|
/**
|
||||||
* Duration of the public leg part in milliseconds. This includes individual legs between public legs, but excludes
|
* 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.
|
* individual legs that lead or trail the trip.
|
||||||
|
*
|
||||||
|
* @return duration in ms, or null if there are no public legs
|
||||||
*/
|
*/
|
||||||
public long getPublicDuration()
|
public Long getPublicDuration()
|
||||||
{
|
{
|
||||||
final Date first = getFirstPublicLegDepartureTime();
|
final Date first = getFirstPublicLegDepartureTime();
|
||||||
final Date last = getLastPublicLegArrivalTime();
|
final Date last = getLastPublicLegArrivalTime();
|
||||||
return last.getTime() - first.getTime();
|
if (first != null && last != null)
|
||||||
|
return last.getTime() - first.getTime();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Minimum time occuring in this trip. */
|
/** Minimum time occuring in this trip. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue