spring boot 接收時間格式慢8小時 和接收不到時分秒 解決

第一個問題 解決
 

@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));
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章