1. Add the
@PostConstruct
void setDefaultTimezone() {
TimeZone.setDefault(TimeZone.getTimeZone(“Asia/Shanghai”));
}
2. Add the
## json setting
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=Asia/Shanghai
3. Add the
public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone(“Asia/Shanghai”));
SpringApplication.run(BaseMicroServiceApplication.class, args);
}
// Otherwise, there will be 8-hour time difference on the server
Or in the database:
After logging in as root, set global time_ zone=’+8:00′;
Mysql database has time zone setting, and the system time zone is used by default
You can query the current time zone through the following statement
show variables like ‘%time_ zone%’;
Read More:
- The time of the time database displayed by the front end is inconsistent
- Solve the problem that the interface between C # WinForm program and Oracle doesn’t respond for a long time
- The problem of [connection lost contact] after C # code connecting Oracle database for a period of time
- Jsonformat annotation solves the problem of time format in the front end of localdatetime
- The problem of strncpy and the solution of GCC compile time checking
- Solve the problem that springboot does not scan @ repository
- How to get the current time in java time string
- After switching the tidb database, an error could not commit JDBC transaction appears from time to time
- Solve the problem of springboot and unit test starting applicationrunner
- When calling time module – time / datetime in wxPython, an error is reported. Valueerror: unknown locale: zh cn
- How to solve the problem of artifact contains illegal characters when creating springboot project with idea
- Solve the problem that the delete request is not available under SpringBoot. There was an unexpected error (type=Method Not Allowed, status=405).
- Linux view current date and time
- MySQL:ERROR 1067 (42000): Invalid default value for ‘end_time’
- Time, strftime and strptime in Python
- Error (1820) if the password is not changed in time after MySQL installation
- The shell gets the current time of the system and formats it
- Non real time fast synchronization scheme for mobile devices
- Error connecting to master, – retry time: 60 retries: 86400
- Set the default time to the current value in MySQL