Spring boot 修改mybatis傳入的日期格式

springboot項目中使用Timestamp類型變量對應mybatis的Timestamp格式的列前端

數據庫中顯示的時間正常,但Spring boot實際獲取的時間格式相似於: "time": "2019-12-31T16:10:00.000+0000", 前端須要使用標準顯示的格式,好比"2019-12-31 16:10:00". spring

後端改更容易一些, 只需在Timestamp變量上加一個@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")便可。 數據庫

完整的Entity以下:後端

@AllArgsConstructor
@Data
public class PriceReturnEntity {

    private String price;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp time;
}

實際JsonFormat還能夠更改時區等等, 這個能夠查看個人另外一篇blogspringboot

相關文章
相關標籤/搜索