@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")失效
时间: 2023-11-11 21:15:07 浏览: 158
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT 8")失效的原因是由于@JsonFormat注解的timezone属性设置不正确。在引用和引用中提到,@JsonFormat注解的timezone属性默认为GMT(即标准时区),而北京位于东八区,所以需要将timezone属性设置为"GMT 8"才能正确地将时间转换为北京时间。所以解决方法是修改@JsonFormat注解的timezone属性为"GMT 8"。如果这样修改之后仍然失效,可以尝试在yml配置文件中进行MySQL配置的修改,如引用所示,可以通过修改jdbc.url参数中的serverTimezone属性来指定时区。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [@JsonFormat(pattern=“yyyy-MM-dd HH:mm:ss“)时差问题](https://blog.csdn.net/weixin_46068874/article/details/118493859)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [记录一下@JsonFormat()的timezone = “GMT+08“失效导致数据库日期时间不一致问题](https://blog.csdn.net/u013138443/article/details/131208199)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文