解決JsonFormat日期少一天問題

使用Jackson的@JsonFormat註解時出現少一天mysql

好比數據庫存的日期是2015-01-05,轉成json則變成了2015-01-04sql

解決辦法:數據庫

@JsonFormat(pattern="yyyy-MM-dd")
 public Date getRegistDate() {
  return this.registDate;
 }json

改爲this

@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
 public Date getRegistDate() {
  return this.registDate;
 }.net

加上時區便可,中國是東八區orm

相關文章
相關標籤/搜索