美文网首页
springboot实体类中时间格式化的处理方式

springboot实体类中时间格式化的处理方式

作者: 千百遍_e69a | 来源:发表于2019-12-31 10:47 被阅读0次

通过SQL处理

通过Jackson的@JsonFormat

接口返回值为时间类型的时候,可以使用@JsonFormat( pattern ="yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")

通过spring的@DateTimeFormat

接口传递时间类型的参数的时候,可以使用 @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")用来把时间字符串转换成pattern格式的时间类型

相关文章

网友评论

      本文标题:springboot实体类中时间格式化的处理方式

      本文链接:https://www.haomeiwen.com/subject/vpkboctx.html