java - Custom deserializer for JodaTime not workin in Spring MVC -
I use a custom jackson serializer to try JSON Joda's date time object to convert according to my desired format I am doing. Beam id = "jacksonmessageChanger" class = "org.springframework.http.converter.json; My custom map class: And finally my serializer: But every time I try, I could not cancel the exception. What am I doing wrong?
& lt: I would like to comment on every case so I can configure it globally MappingJacksonHttpMessageConverter "& gt; & Lt; Property Name = "Supported MediaTaps" value = "App / JSON" /> & Lt; Property name = "objectmapper" ref = "jackson objectmapper" /> & Lt; / Bean & gt; & Lt; Bean id = "Jackson ObjectMaper" class = "com.myapp.CustomJacksonObjectMapper" />
Public class CustomJacksonObjectMapper extends ObjectMapper {public CustomJacksonObjectMapper () {CustomSerializerFactory factory = new CustomSerializerFactory (); Factory.Educational Mapping (Datetime, Class, New Daytime Surgery); This.setSerializerFactory (factory); }}
Public class DateTimeSerializer extends JsonSerializer & LT; Date Time & gt; {Private Static DateTimeFormatter Format = DateTimeFormat.forPattern ("dd-mm -yyyy"); Private Static Logger Logger = LoggerFactory.getLogger (DateTimeSerializer.class); @Override Public Zero Serialize (DATETIME Value, JsonGenerator jgen, SerializerProvider Provider) IOException, JsonProcessingException {String throws formattedDate = formatter.print (value); Logger.debug ("change date string: {}", formatted data); Jgen.writeString (formattedDate); }}
Comments
Post a Comment