MongoDB 時區問題,mongodb時區問題

來源:互聯網
上載者:User

MongoDB 時區問題,mongodb時區問題

由於工作的原因,我最近在弄資料庫是mongoDB的java項目。發現項目中的時間出現問題,每次儲存資料的時候時間都會少掉8個小時。

解決辦法

在設定時間變數前添加註解

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")

pattern是時間格式設定(HH表示24小時制,hh表示12小時制),timezone是時區設定,我們這裡是東八區,所以設定為這個。


這個方法來之不易,忍不住為自己點贊!哈哈哈哈

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.