/** * Print out some details about a segment. This is far from all the available information. * * @param segment the segment to be displayed * @param fmt the formatter to use to display the data */ public void printLeg(AirSegment segment, Formatter fmt) { Date dep = Helper.dateFromISO8601(segment.getDepartureTime()); fmt.format( "AIR Departing from %3s to %3s on %Tc\n", segment.getOrigin(), segment.getDestination(), dep); fmt.format( " Flight [%2s]#%4s Flight time: %s minutes\n", segment.getCarrier(), segment.getFlightNumber(), segment.getFlightTime()); fmt.format( " Arrive %Tc\n", Helper.dateFromISO8601(segment.getArrivalTime())); }
public void printJourney(RailJourney journey, Formatter fmt) { Date dep = Helper.dateFromISO8601(journey.getDepartureTime()); fmt.format( "RAIL (%s) From %s to %s on %Tc\n", journey.getJourneyDirection(), journey.getOriginStationName(), journey.getDestinationStationName(), dep); List<RailSegmentRef> onThisJourney = journey.getRailSegmentRef(); for (Iterator<RailSegmentRef> rsIter = onThisJourney.iterator(); rsIter.hasNext(); ) { RailSegment railSegment = railSegments.get(rsIter.next().getKey()); if (railSegment.getOperatingCompany() == null) { fmt.format(" METRO"); } else { fmt.format( " %s[%2s] Train #%4s ", railSegment.getOperatingCompany().getName(), railSegment.getOperatingCompany().getCode(), railSegment.getTrainNumber()); } fmt.format( " --- From " + railSegment.getOriginStationName() + " to " + railSegment.getDestinationStationName()); if (railSegment.getTravelTime() != null) { fmt.format("Travel time: %s minutes\n", railSegment.getTravelTime()); } else { fmt.format("\n"); } } fmt.format( " Arrive %Tc\n", Helper.dateFromISO8601(journey.getArrivalTime())); }