Firstly I use @JsonFormat to format a date which was selected from the database, like this:
@JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
Then I realized that the return value to the front end is wrong(it is different from the value of the database), so I added time zone, like this:
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
Problem solved!