问答详情
源自:6-3 增加接口开发

java.lang.IllegalArgumentException: Invalid format: "2017-11-17T16:00:00.000Z" is malformed at "T16:00:00.000Z"

@PostMapping("/add/book/novel")
public ResponseEntity add(@RequestParam(name = "title") String title,
                          @RequestParam(name = "author") String author,
                          @RequestParam(name = "word_count") String wordCount,
                          @RequestParam(name = "public_date")
                          @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
                                  Date publicDate
Date publicDate 就会报上边的错,改为string就不报错


提问者:北极的大企鹅 2018-11-18 02:22

个回答

  • 慕仰7497274
    2018-11-24 19:56:37
    已采纳

    封装一个类,然后把这个

    @DateTimeFormat

    注解在字段上面

    @DateTimeFormat
    private Date publicDate