2
2
3
3
import java .time .Instant ;
4
4
import java .time .LocalDate ;
5
- import java .time .ZoneId ;
6
- import java .time .ZonedDateTime ;
7
5
import java .util .ArrayList ;
8
6
import java .util .Comparator ;
9
7
import java .util .List ;
@@ -169,8 +167,11 @@ public int getScheduledArrival() {
169
167
return tripTimes .getScheduledArrivalTime (stopIndex );
170
168
}
171
169
172
- public ZonedDateTime scheduledArrivalAt (ZoneId zoneId ) {
173
- return toZonedDateTime (getScheduledArrival (), zoneId );
170
+ /**
171
+ * Returns the scheduled arrival as an Instant.
172
+ */
173
+ public Instant scheduledArrival () {
174
+ return toInstant (getScheduledArrival ());
174
175
}
175
176
176
177
/**
@@ -184,8 +185,11 @@ public int getScheduledDeparture() {
184
185
return tripTimes .getScheduledDepartureTime (stopIndex );
185
186
}
186
187
187
- public ZonedDateTime scheduledDepartureAt (ZoneId zoneId ) {
188
- return toZonedDateTime (getScheduledDeparture (), zoneId );
188
+ /**
189
+ * Returns the scheduled departure as an Instant.
190
+ */
191
+ public Instant scheduledDeparture () {
192
+ return toInstant (getScheduledDeparture ());
189
193
}
190
194
191
195
public int getRealtimeArrival () {
@@ -393,17 +397,17 @@ public List<TripTimeOnDate> nextTimes() {
393
397
}
394
398
395
399
/**
396
- * Returns the real time arrival, if available, at the given zone .
400
+ * Returns the real time arrival, if available.
397
401
*/
398
- public Optional <ZonedDateTime > realtimeArrivalAt ( ZoneId zoneId ) {
399
- return optionalZonedDateTime (getRealtimeArrival (), zoneId );
402
+ public Optional <Instant > realtimeArrival ( ) {
403
+ return optionalInstant (getRealtimeArrival ());
400
404
}
401
405
402
406
/**
403
- * Returns the real time departure, if available, at the given zone .
407
+ * Returns the real time departure, if available.
404
408
*/
405
- public Optional <ZonedDateTime > realtimeDepartureAt ( ZoneId zoneId ) {
406
- return optionalZonedDateTime (getRealtimeDeparture (), zoneId );
409
+ public Optional <Instant > realtimeDeparture ( ) {
410
+ return optionalInstant (getRealtimeDeparture ());
407
411
}
408
412
409
413
private TripTimeOnDate atStopIndex (int stopIndex ) {
@@ -420,15 +424,15 @@ private TripTimeOnDate atStopIndex(int stopIndex) {
420
424
* If real time data is available for this stop (call) then it is returned or an empty Optional
421
425
* otherwise.
422
426
*/
423
- private Optional <ZonedDateTime > optionalZonedDateTime (int secondsSinceMidnight , ZoneId zoneId ) {
427
+ private Optional <Instant > optionalInstant (int secondsSinceMidnight ) {
424
428
if (isCancelledStop () || isRealtime ()) {
425
- return Optional .of (toZonedDateTime (secondsSinceMidnight , zoneId ));
429
+ return Optional .of (toInstant (secondsSinceMidnight ));
426
430
} else {
427
431
return Optional .empty ();
428
432
}
429
433
}
430
434
431
- private ZonedDateTime toZonedDateTime (int secondsSinceMidnight , ZoneId zoneId ) {
432
- return Instant .ofEpochSecond (midnight ).plusSeconds (secondsSinceMidnight ). atZone ( zoneId ) ;
435
+ private Instant toInstant (int secondsSinceMidnight ) {
436
+ return Instant .ofEpochSecond (midnight ).plusSeconds (secondsSinceMidnight );
433
437
}
434
438
}
0 commit comments