gpt4 book ai didi

Java减去LocalTime

转载 作者:IT老高 更新时间:2023-10-28 21:07:30 24 4
gpt4 key购买 nike

我有两个 LocalTime 对象:

LocalTime l1 = LocalTime.parse("02:53:40");
LocalTime l2 = LocalTime.parse("02:54:27");

我怎样才能发现它们之间的分钟数不同?

最佳答案

使用 untilbetween,如 api 所述

import java.time.LocalTime;
import static java.time.temporal.ChronoUnit.MINUTES;

public class SO {
public static void main(String[] args) {
LocalTime l1 = LocalTime.parse("02:53:40");
LocalTime l2 = LocalTime.parse("02:54:27");
System.out.println(l1.until(l2, MINUTES));
System.out.println(MINUTES.between(l1, l2));
}
}

0
0

关于Java减去LocalTime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28353725/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com