Milestone 2: Cannot construct instance of java.time.LocalDate (no Creators, like default construct, exist)

While sending the url for the getForObject method, I am facing this error. When I am trying to extract PurchaseDate attribute from the JSON file, for adding in URL, I am facing this error.

“cause”:“com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of java.time.LocalDate (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value (‘2019-01-02’)\n at [Source: (File); line: 6, column: 21] (through reference chain: java.lang.Object[][0]->com.crio.warmup.stock.dto.PortfolioTrade[“purchaseDate”])”}
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of java.time.LocalDate (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value (‘2019-01-02’)
at [Source: (File); line: 6, column: 21] (through reference chain: java.lang.Object[][0]->com.crio.warmup.stock.dto.PortfolioTrade[“purchaseDate”])

I am repeatedly facing this error. I tried solutions of stackoverflow but none of them worked.

This error might be occuring because datatype of PurchaseDate from json file and datatype of startDate in URL are not same.

I know that but even after converting it to the required dataType, it throws the same error. Even when just Printing it out.

1 Like


try this .

2 Likes

Thank you so much bro! It worked!!! :relieved:

1 Like