Spring boot接收Date時間類型參數 postman傳入方式

接收Date類型時不知道該傳入什麼,然後總是報這樣的錯

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors

Field error in object 'xxx' on field 'beginAt': rejected value [2018-6-24 21:39:58]; codes [typeMismatch.xxx.beginAt,typeMismatch.beginAt,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [xxx.beginAt,beginAt]; arguments []; default message [beginAt]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'beginAt'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@com.fasterxml.jackson.databind.annotation.JsonSerialize java.util.Date] for value '2018-6-24 21:39:58'; nested exception is java.lang.IllegalArgumentException]

查了好多資料,終於找到正確的格式了,記錄一下

其實很簡單,傳入 2018/7/7 11:11:00 這種格式就可以了



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章