亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將 millis 轉換為 ZonedDateTime 不起作用

將 millis 轉換為 ZonedDateTime 不起作用

手掌心 2023-09-20 15:32:54
我有這個毫秒:1570046362841使用版本 1進行轉換時:var myDate = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1570046362841), ZoneId.of("America/New_York"));我會得到這個結果(這是錯誤的?。?51722-10-16T03:58:54-04:00[America/New_York]但是,當使用版本 2進行轉換時: final String dateFormat = "yyyy-MM-dd HH:mm:ss SSS"; SimpleDateFormat formatter = new SimpleDateFormat(dateFormat); formatter.setTimeZone(TimeZone.getTimeZone("America/New_York")); var dateObj = new Date(1570046362841); var myDate = formatter.format(dateObj);我得到正確的結果:2019-10-02 15:59:59 934為什么版本1是錯誤的?版本 1 有什么問題?
查看完整描述

1 回答

?
largeQ

TA貢獻2039條經驗 獲得超8個贊

而不是Instant.ofEpochSecond()你需要使用,Instant.ofEpochMilli()因為你有毫秒。



查看完整回答
反對 回復 2023-09-20
  • 1 回答
  • 0 關注
  • 89 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號