1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > java -09-21T10:41:00.000+0800 转换成 yyyy-MM-dd HH:mm:ss

java -09-21T10:41:00.000+0800 转换成 yyyy-MM-dd HH:mm:ss

时间:2019-06-09 00:44:34

相关推荐

java -09-21T10:41:00.000+0800 转换成 yyyy-MM-dd HH:mm:ss

1.背景描述

在数据库里的时间格式为: DATE 类型

-09-2110:41:00

接口返回时,格式变成了

-09-21T10:41:00.000+0800

2.解决方法

一般情况下在实体类字段上加@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 注解能解决90%的情况

import java.util.Date;import com.fasterxml.jackson.annotation.JsonFormat;import org.springframework.format.annotation.DateTimeFormat;@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")private Date gmtCreate;

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。