如何在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 教师闺蜜祝福语简短