Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Resolve the issue where the insertion date is less than 8 hours

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

This problem has been perplexed for a long time. Originally thought to be the database problem of mysql, directly modify the configuration file my.cnf (in / etc/my.cnf or / etc/mysql/my.cnf), but restart mysql after modification is also invalid. Later, there was no such problem in the local mode. Later, it was suspected that there was a problem with the jdk installed on Ali CVM. After testing, the solution is as follows:

/ * *

@ Title: getCurrentServerTime@Description: get the current server time @ return

, /

Public static String getCurrentServerTime () {

Date date = new Date ()

SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMdd HH:mm:ss")

Sdf.setTimeZone (TimeZone.getTimeZone ("Asia/Shanghai"))

String currentServerTime = sdf.format (date)

Return currentServerTime

}

Add this code directly to sdf.setTimeZone (TimeZone.getTimeZone ("Asia/Shanghai"))

Redeploy the project to the server and found that it was successful.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report