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

通过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实体类中时间格式化的处理方式)