swagger-codegen-maven-plugin

How do I update RestTemplate to correctly map Java Dates?

◇◆丶佛笑我妖孽 提交于 2019-12-02 07:43:55
问题 I have an issue where my RestTemplate.postForEntity(url, restRequest, RepoResponse.class) call is failing because it can't deserialise dates of the form: 2019-02-01T12:00:00.000-0500 because of the missing colon in the timezone. Based on this answer, it looks like I want to change the date formatting of my RestTemplate 's ObjectMapper . I've tried a solution here: https://stackoverflow.com/a/38286322/14250 Which gives me the following code: restTemplate = new RestTemplate(); ObjectMapper

How do I update RestTemplate to correctly map Java Dates?

橙三吉。 提交于 2019-12-02 04:12:07
I have an issue where my RestTemplate.postForEntity(url, restRequest, RepoResponse.class) call is failing because it can't deserialise dates of the form: 2019-02-01T12:00:00.000-0500 because of the missing colon in the timezone. Based on this answer , it looks like I want to change the date formatting of my RestTemplate 's ObjectMapper . I've tried a solution here: https://stackoverflow.com/a/38286322/14250 Which gives me the following code: restTemplate = new RestTemplate(); ObjectMapper objectMapper = new ObjectMapper(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss