import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.ValueFilter;
ListresultZhibaoList= zhibaoService.queryZhibaoList(zhibao);
//拦截,处理日期格式
ValueFilter valueFilter = new ValueFilter() {
@Override
public Object process(Object obj, String key, Object value) {
if(value instanceof Timestamp){
Timestamp timestamp = (Timestamp) value;
return DateUtils.parseDate(timestamp,"yyyy-MM-dd");
}else{
return value;
}
}
};
//List排序Collections.sort(resultZhibaoList, new Comparator() {
public int compare(ResultZhibao arg0, ResultZhibao arg1) {
return arg1.getZhibaoNumber().compareTo(arg0.getZhibaoNumber());
}
});
//List 转 JSON
String dataList = JSON.toJSONString(resultZhibaoList, valueFilter);
网友评论