diff --git a/src/main/java/com/ann/demo/utils/XMLUtils.java b/src/main/java/com/ann/demo/utils/XMLUtils.java index 16f4a5f..1157fd2 100644 --- a/src/main/java/com/ann/demo/utils/XMLUtils.java +++ b/src/main/java/com/ann/demo/utils/XMLUtils.java @@ -62,9 +62,9 @@ public class XMLUtils { doctorDataPath = doctorDataPathTemp; } - private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss"); + // private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss"); // 病案首页独享 - private static SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + // private static SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); /** * 生成普通xml字符串 @@ -149,6 +149,8 @@ public class XMLUtils { PropertyDescriptor descriptor = new PropertyDescriptor(key, obj.getClass()); if (("class java.util.Date").equals(objField)) { if (value != null && value.length() > 0) { + // 20200526 将时间格式定义成局部变量 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss"); Date parse = simpleDateFormat.parse(value, new ParsePosition(0)); descriptor.getWriteMethod().invoke(obj, parse); } @@ -162,6 +164,8 @@ public class XMLUtils { // 给messageDto赋值 if (("class java.util.Date").equals(messageField)) { if (value != null && value.length() > 0) { + // 20200526 将时间格式定义成局部变量 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss"); propertyDescriptor.getWriteMethod().invoke(messageDto, simpleDateFormat.parse(value, new ParsePosition(0))); } } else {