第一个问题 解决
@ApiModelProperty(value = "创建时间",required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@Column(name="create_date")
private Date createDate;
或者在配置文件
spring: jackson: time-zone: GMT+8
第二个问题 接收不到时分秒
原因我在baseController 之前就写了 接收的格式
@InitBinder public void initBinder(ServletRequestDataBinder binder) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true)); }
所以接收不到.
改成
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
}