Ismail Seyfi's Blog: How to control Date formatting when Jackson JSON Processor is used with Spring 3.0
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
public class DateSerializer extends JsonSerializer<Date> {
@Override
public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
JsonProcessingException {
DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
String formatted = formatter.format(value);
jgen.writeString(formatted);
}
}
@JsonSerialize(using = DateSerializer.class)
public Date getEntryDate() {
return entryDate;
}