提问人:JJD 提问时间:9/8/2018 更新时间:9/8/2018 访问量:82
如何从没有时区偏移量的 UTC 毫秒值计算一天中的分钟数?
How to calculate minutes of the day from a UTC milliseconds value w/o time zone offset?
问:
给定以下时间戳...
2018-09-07T17:00:00+02:00
对应于 ..
UTC: 1536332400000 milliseconds
我喜欢使用 ThreeTen 向后移植库来计算一天中的分钟数:
val dateUtc = 1536332400000L
val offset = ZoneOffset.ofHours(2) // taken from the time stamp
val offsetDateTime = Instant.ofEpochMilli(dateUtc).atOffset(offset)
val minutes = offsetDateTime.get(ChronoField.MINUTE_OF_DAY)
到目前为止,以上工作正常。
有没有办法避免定义区域偏移量,因为 UTC 毫秒已经隐含了 的区域偏移量?0
相关
- https://www.epochconverter.com - 用于获取毫秒值
答: 暂无答案
评论