In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how many hours is the difference between springboot timestamp and database time". In daily operation, I believe many people have doubts about the difference between springboot timestamp and database time. Xiaobian consulted all kinds of information and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "how many hours is the difference between springboot timestamp and database time?" Next, please follow the editor to study!
The difference between springboot time stamp and database time is 14 hours.
A strange problem encountered in springboot development is that the system time GMT+8 has been set, but the time will be reduced by 14 hours when it reaches the database. It was later found that the jvm time zone and the database time zone settings were inconsistent.
Jvm sets GMT+8 and the database is the CST time zone. The CST time zone is chaotic, which can cause a difference of 13 or 14 hours in winter or daylight saving time, so you need to change it to what you need.
Time zone setting during spring development
1 jvm system time zone setting, in application.yml configuration file
Spring: jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8
2 in the request parameters, use JsonFormat to configure resolution rules
Import com.fasterxml.jackson.annotation.JsonFormat; @ JsonFormat (pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date birthday
3 set the parsing time zone in the database connection, this method does not require the mysql server to set the time zone and then restart
Jdbc:mysql://localhost:3306/table_name?useUnicode=true&characterEncoding=UTF-8&useSSL=false&useTimezone=true&serverTimezone=GMT%2B8
After the above settings, the request timestamp and runtime timestamp are consistent with the database timestamp.
4 database view time zone command
Show variables like'% time_zone%'; here, on the "springboot timestamp and database time difference of how many hours" study is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.