分解单加字段!! 标准评估流程 数据补充
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.ydw.bat.wkflow.util;
|
||||
|
||||
import com.ydw.bat.wkflow.business_main.datas.dto.PEPres;
|
||||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JsonConfig;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class DealWithDate {
|
||||
|
||||
public static String delWithTime(PEPres a){
|
||||
JsonConfig jsonConfig = new JsonConfig();
|
||||
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
|
||||
JSONObject jsonObject = JSONObject.fromObject(a,jsonConfig);
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ydw.bat.wkflow.util;
|
||||
|
||||
import net.sf.json.JsonConfig;
|
||||
import net.sf.json.processors.JsonValueProcessor;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class JsonDateValueProcessor implements JsonValueProcessor {
|
||||
|
||||
private String datePattern = "yyyy-MM-dd HH:mm:ss";//默认样式,可以在构造方法中修改
|
||||
public JsonDateValueProcessor() {
|
||||
super();
|
||||
}
|
||||
public JsonDateValueProcessor(String datePattern) {
|
||||
super();
|
||||
this.datePattern = datePattern;
|
||||
}
|
||||
public Object processArrayValue(Object value, JsonConfig jsonConfig) {
|
||||
try {
|
||||
if(value instanceof Date){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
|
||||
Date date = (Date)value;
|
||||
return sdf.format(date);
|
||||
}
|
||||
return value == null ? null : value.toString();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
|
||||
return processArrayValue(value, jsonConfig);
|
||||
}
|
||||
public String getDatePattern() {
|
||||
return datePattern;
|
||||
}
|
||||
public void setDatePattern(String datePattern) {
|
||||
this.datePattern = datePattern;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user