You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written custom serializer for java.util.Date, code as follows
public class DateMapper extends JsonSerializer<Date>{
@Override
public void serialize(Date dateObje, JsonGenerator jgen, SerializerProvider serializers) throws IOException, JsonProcessingException {
// TODO Auto-generated method stub
String formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(dateObje);
jgen.writeString(formattedDate);
}
}
And I am trying to register it as follows
@Configuration
public class Mapper extends WebMvcConfigurerAdapter {
@Bean
public JsonViewSupportFactoryBean views() {
JsonViewSupportFactoryBean bean = new JsonViewSupportFactoryBean();
bean.registerCustomSerializer(Date.class, new DateMapper());
return bean;
}
}
But its not working, not sure why.
I have tried the same way for string and its working fine.
The text was updated successfully, but these errors were encountered:
I have written custom serializer for java.util.Date, code as follows
And I am trying to register it as follows
But its not working, not sure why.
I have tried the same way for string and its working fine.
The text was updated successfully, but these errors were encountered: