mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 15:39:50 +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;
|
||||
}
|
||||
|
||||
/** 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()
|
||||
{
|
||||
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
|
||||
* 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 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. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue