參考centos7市區更改
場景
在使用@JsonFormat(pattern=“yyyy-MM-dd HH:mm:ss”,timezone=“GMT+8”)進行背景日期往前台傳輸序列化後日期,還是有差别,原因是jsonformat會根據時區進行調整,伺服器作業系統時區不是标準時區。将伺服器上日期與開發機器比較發現,兩者的系統時間不同
centos檢視系統時間指令
date
解決
參考:https://www.cnblogs.com/xsbx/p/10172728.html。修改了伺服器的時區,成功解決該問題。
檢視系統支援的時區清單
timedatectl list-timezones
使用 date -R 檢視時區是否正确
date -R
修改時區
timedatectl set-timezone Asia/Shanghai
安裝NTP
安裝之前先安裝
yum install epel-release
安裝ntp工具
sudo yum -y install ntp
使用 ntpdate 更新系統時間
ntpdate pool.ntp.org
使用 date 檢視時區是否正确
date
啟動ntpd daemon,持續校準時間
systemctl start ntpd
檢視ntpd daemon是否啟動
systemctl status ntpd