我有一个航班行程计划,我需要了解出发和到达时间之间的差异。我从数据中得到这些指定的时间作为字符串。这是我的问题:
import static java.time.temporal.ChronoUnit.MINUTES;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class test2 {
public static void main(String[] args) {
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("HHmm");
LocalTime departure = LocalTime.parse("1139", dateFormat);
LocalTime arrival = LocalTime.parse("1435", dateFormat);
LocalTime a = LocalTime.parse("0906", dateFormat);
System.out.println(MINUTES.between(departure, arrival));
System.out.println(MINUTES.between(arrival, a));
}
}
输出:
176
-329
第一次返回 11:39 和 14:35 之间的差异就好了。但第二个差异只有 5 小时,而应该是 19 小时。我该如何解决这个问题,我在这里做错了什么?
任何帮助将不胜感激。
编辑:我正在使用图表来存储我的数据。两个机场之间最短路线的示例如下:
Route for Edinburgh to Sydney
1 Edinburgh, 1139, TK3245, Istanbul, 1435
2 Istanbul, 0906, TK4557, Singapore, 1937
3 Singapore, 0804, QF1721, Sydney, 1521
这些是我们从 EDI 到 SYD 的 3 个航班。上面输出的格式是(城市、出发时间、航班号、目的地、到达时间)。
吃鸡游戏
哈士奇WWW
相关分类