Can not make POST, getting error "Cannot deserialize value of type `java.time.LocalDateTime` from Object value"

334 Views Asked by At

I have built android app. The application gets date from a string field. I parse that string to right format to get LocalDateTime.

DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

LocalDateTime date = LocalDateTime.parse(routeDate.getText().toString(), dateTimeFormatter);

but when i make post request it fails. My backend is springboot app. I get from it error:

WARN 29948 --- [nio-8080-exec-5] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.time.LocalDateTime` from Object value (token `JsonToken.START_OBJECT`)<EOL> at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 9] (through reference chain: com.university.logisticsappbe.model.api.CreateCheckpointRequest["date"])]

By logging out date to console I get 2022-02-02T10:00

Any ideas what problem it could be?

On angular web application post works.

0

There are 0 best solutions below