dob : any = "15-05-2001";
When sending to server it returns the error Could not read document: Can not construct instance of java.util.Date from String value '15-05-2001': not a valid representation (error: Failed to parse Date value '15-05-2001': Can not parse date \"15-05-2001\": not compatible with any of standard forms (\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\", \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", \"EEE, dd MMM yyyy HH:mm:ss zzz\", \"yyyy-MM-dd\"))\n
In Angular code tried to convert the the date
dob = new Date(moment(dob, "DD-mm-yyyy").format("MM-DD-YYYY")).getTime();
returns 1581710400000
which returns wrong date, but server accepted the input.
How can I format this date, so that I can send the required date and server accepts same.
Same problem occurred and my solution was i have converted datetime
into toLocalString
.
var dateTime = new Date();
var sendObj = dateTime.now().toLocalString();
UPDATE:
dob = "15-05-2001";
dob = new Date(moment(this.dob, "dd-MM-YYYY").format()).getTime();