From d8ad086f8eb102206dd8ca17e5e9ee920c47dbe1 Mon Sep 17 00:00:00 2001 From: leijx <1477272687@qq.com> Date: Fri, 29 May 2020 15:22:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ann/demo/utils/XMLUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 {