TIMESTAMP in MySQL datetime data type with T
First, the scene description:
TIMESTAMP type using MySQL
entity class type used java.util.Date
return JSON data:
Second, by annotation format (Method a)
Date type attribute may be on, or coupled with the GET method of Jackson @JsonFormat annotations formatted manner, for example:
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
result:
Second, through the global configuration (Method B)
@Configuration
public class WebMvcConfig {
@Bean
MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
converter.setObjectMapper(mapper);
return converter;
}
}