I have a string : “14 Feb 2012” that I want to des

2019-08-22 03:56发布

How do I create my own json mapping serialization/desrialization ?

Using spring 3.1 annotions.

@RequestMapping(value = "/Save", method = RequestMethod.POST)
public String saveDTO(@Valid @RequestBody final myDTO myDTO,Model model){

where myDTO contains a LocalDate, and I have correctly created the json using jquery/javascript, the error message is so :

Caused by: java.lang.IllegalArgumentException: Invalid format: "14-Feb-2012" is malformed 
at "-Feb-2012" at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:866)

1条回答
霸刀☆藐视天下
2楼-- · 2019-08-22 04:48

Did you try adding @DateTimeFormat annotation to LocalDate with this date format dd-MMM-yyyy i.e.

@DateTimeFormat(pattern = "dd-MMM-yyyy")
Date LocalDate;
查看更多
登录 后发表回答