I have a simple rest service to store time range, however, Spring cannot parse datetime format with timezone correctly.
the Entity is
@Data
@Entity
public class TimeRange {
@Setter(AccessLevel.NONE)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = true)
private LocalDateTime startTime;
@Column(nullable = true)
private LocalDateTime endTime;
}
The controller is:
@PostMapping(path = "/time", consumes = "application/json", produces = "application/json")
public Boolean setTime(@RequestBody TimeRange timeRange) {
    timeRangeRepository.save(timeRange);
    return true;
}
and the actuall request is
url = f'http://localhost/api/time'
data = {
  "startTime": "2019-12-03T19:58:29.047820+08:00",
  "endTime": "2019-12-04T19:58:29.047820+08:00"}
resp = requests.post(url, json=data, timeout=10)
pprint(resp.json())
spring reported an error said:
 esolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: 
Cannot deserialize value of type `java.time.LocalDateTime` from String "2019-12- 
03T19:58:29.047820+08:00": Failed to deserialize java.time.LocalDateTime: 
    (java.time.format.DateTimeParseException) Text '2019-12-03T19:58:29.047820+08:00' could not be 
    parsed, unparsed text found at index 26; nested exception is 
    com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type 
    java.time.LocalDateTime from String "2019-12-03T19:58:29.047820+08:00": Failed to deserialize 
   java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2019-12- 
  03T19:58:29.047820+08:00' could not be parsed, unparsed text found at index 26
    at
 
     
    