如何在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 官宣新年祝福语简短