-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels