This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Java 8 LocalDate Jackson format

 
Ranch Hand
Posts: 44
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am facing one very known issue yet no solution is working for me. Any quick help will be grateful
From MVC controller, I am calling REST service which returns me Model object with LocalDate as one of the fields.  JacksonJAXbJSONProvider  does not parse the Localdate object. I wrote custom Mapper as below And dependency is added in pom.xml



This was suggested in http://stackoverflow.com/questions/28802544/java-8-localdate-jackson-format/38051405#38051405

My spring.xml(contains configuration for MVC controller etc...) has already one mapper configured which does conversion automatically as below



Below is stub file which connects to REST Service



Now How do I configure my Context resolver which I just wrote so that I should be able to convert LocalDate.

Where should my custom class go, in message converter or jaxrs:providers> ?

I am getting below exception


No suitable constructor found for type [simple type, class java.time.LocalDate]: can not instantiate from JSON object (need to add/enable type information?)
 
Surinder Mehra
Ranch Hand
Posts: 44
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved it. below is my code. Note :All Objects from org.codehaus not from fasterxml except from java.time.LocalDate and Time. Hope it helps someOne





Server side configuration


Client side configarion


 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! This really solved my issue too.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic