后端接受前端的时间是yyyy-mm-ss格式,但是使用mybatis查询这个时间的时候,会变成yyyy-MM-ss 08:00:00, 自动加上八小时,不是我想要的0时,就导致查询的时候出现了很多错误数据
接受时间的实体,需要加上JsonFormat 注解
java @ApiModelProperty(value="出院时间开始")
@NotNull(message = "出院开始时间不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date dischargeTimeBegin;
@ApiModelProperty(value="出院时间截止")
@NotNull(message = "出院截止时间不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date dischargeTimeEnd;
因为jsonformat是对json格式有效,会格式化返回值,他和@DateTimeFormat注解是相辅相成的,具体可以看我的这篇文章
本文作者:Weee
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
预览: