Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-03 06:47:44 09月21日 Update

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.

Tags: Problem server service success code data database file method time mode project Ali test configuration hour date Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS NVidia Shulou Technology vpn