When storing an entity, if a time is stored and then read out, if it is 8 hours behind, it is probably Greenwich Mean Time (GMT).
Solution:
There are two options:
- When reading, read it as GMT+8.
- When storing, store it as GMT+8.
The first option is to specify the time zone of the database.
[mysqld]
default-time-zone = '+8:00'
The second option is to add @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
to the field in the entity class.