日期:2014-05-16 浏览次数:20377 次
public class CustomDateSerializer extends JsonSerializer<Date> { @Override public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String formattedDate = formatter.format(value); jgen.writeString(formattedDate); } }
@JsonSerialize(using = CustomDateSerializer.class) public Date getCreateAt() { return createAt; }