com.fasterxml.jackson.databind.exc.InvalidFormatException

com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDate` from String "2020-03-03T00:00:00+00:00": Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '2020-03-03T00:00:00+00:00' could not be parsed, unparsed text found at index 19
 at [Source: (String)"[{"adjClose":289.32,"adjHigh":304.0,"adjLow":285.8,"adjOpen":303.67,"adjVolume":79868852,"close":289.32,"date":"2020-03-03T00:00:00+00:00","divCash":0.0,"high":304.0,"low":285.8,"open":303.67,"splitFactor":1.0,"volume":79868852}]"; line: 1, column: 112] (through reference chain: java.lang.Object[][0]->com.crio.warmup.stock.dto.TiingoCandle["date"])

I am using getObjectMapper function still recieving this error. I am stuck here for a long time and not able to move forward.

Hey, you need to deserialize the json data using java time module.

You mean using this ?

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());

It’s already implemented in getObjectMapper so it’s already in use.

Did check you imports, is the java time module imported correctly.

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

Yes it is imported correctly.

Okay, inside the TiingoCandle.java file just add these 2 annotations above the LocalDate date variable within the TiingoCandle class

@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)

make sure to quick fix the necessary imports

It’s same error. Nothing changed.

Wait give me some time, till i check your code.

1 Like

Hey, i checked your code. The url which you are using is not correct, it doesn’t contain parameters (i.e startDate and endDate)

Thanks for the help. It was my bad to not to read properly in hurry of completing modules.