• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java 8 LocalDate Jackson format

 
Ranch Hand
Posts: 44
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! This really solved my issue too.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic