gpt4 book ai didi

java - 我如何将大数字转换为 ZonedDateTime java 字段

转载 作者:行者123 更新时间:2023-11-30 05:27:01 25 4
gpt4 key购买 nike

如何将这样的数字:1467158498669从json文件转换为类型为ZonedDateTime的java字段?

谢谢!

最佳答案

您可以使用Instant.ofEpochMilli

long date = 1467158498669l;

ZonedDateTime zoneTime = Instant.ofEpochMilli(date).atZone(ZoneId.of("Canada/Atlantic"));

或者

ZonedDateTime  zdt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(date),
ZoneId.of("Canada/Atlantic"));

关于java - 我如何将大数字转换为 ZonedDateTime java 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58355533/

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