gpt4 book ai didi

java - 如何将 System.currentMillis 秒转换为 TemporalAccessor

转载 作者:行者123 更新时间:2023-12-01 17:45:43 24 4
gpt4 key购买 nike

我需要将标准的长 System.currentmillis 转换为临时访问器,但不知道如何开始。

最佳答案

Instant是一个 TemporalAccessor,因此您可以从纪元以来的毫秒数创建一个 Instant:

TemporalAccessor ta = Instant.ofEpochMilli(System.currentTimeMillis());

请注意 System.currentTimeMillis 的文档表示该值的粒度取决于操作系统,因此可能不是以毫秒为单位的精确时间。

Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.

关于java - 如何将 System.currentMillis 秒转换为 TemporalAccessor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55559376/

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