Resolve the issue where the insertion date is less than 8 hours
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.