我有一个很长的时间戳 1499070300(相当于星期一,2017 年 7 月 3 日 16:25:00 +0800)但是当我将它转换为 LocalDateTime 我得到 1970-01-18T16:24:30.300
这是我的代码
long test_timestamp = 1499070300;
LocalDateTime triggerTime =
LocalDateTime.ofInstant(Instant.ofEpochMilli(test_timestamp), TimeZone
.getDefault().toZoneId());
原文由 rhandom 发布,翻译遵循 CC BY-SA 4.0 许可协议
您需要以毫秒为单位传递时间戳:
结果:
或者使用
ofEpochSecond
代替:结果: