如何在Java中获得两个即时时间戳之间的持续时间
让我们首先ofEpochSeconds()使用从1970-01-01T00:00:00Z的纪元开始的秒数来设置两个Instant方法。
现在获取上述两个即时之间的持续时间:
Duration res = Duration.between(one, two);
示例
import java.time.Duration;
import java.time.Instant;
public class Demo {
public static void main(String[] args) {
Instant one = Instant.ofEpochSecond(1845836728);
Instant two = Instant.ofEpochSecond(1845866935);
Duration res = Duration.between(one, two);
System.out.println(res);
}
}输出结果
PT8H23M27S
热门推荐
10 新郎表白成语祝福语简短
11 许愿星姐妹祝福语简短
12 结婚转账祝福语高级简短
13 宝宝新生入学祝福语简短
14 空军大学开学祝福语简短
15 祝球员赛前祝福语简短
16 新婚迎宾海报祝福语简短
17 孙女结婚姥姥祝福语简短
18 老板茶楼开业祝福语简短