• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

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.
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic