I need to invoke and api, which needs date in the below format
"createdOn": "2020-07-16T13:30:29.470Z",
I am trying the below code
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String createdDate = simpleDateFormat.format(Calendar.getInstance().getTime());
System.out.println("createdDate :::::" + createdDate);
but I am getting the below exception
2020-07-16 18:58:10.034 WARN 15244 --- [nio-9085-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String "2020-07-16 18:58:10": not a valid representation (error: Failed to parse Date value '2020-07-16 18:58:10': Cannot parse date "2020-07-16 18:58:10": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null)); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "2020-07-16 18:58:10": not a valid representation (error: Failed to parse Date value '2020-07-16 18:58:10': Cannot parse date "2020-07-16 18:58:10": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))
at [Source: (PushbackInputStream); line: 1, column: 74]]