From d22d44ba96bec18807f94a607d4e78a25b749fc1 Mon Sep 17 00:00:00 2001 From: luoyang Date: Tue, 9 Apr 2019 14:16:27 +0800 Subject: [PATCH] =?UTF-8?q?fix=20format=E5=A4=8F=E6=97=B6=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/manage/appclient/beans/AppQueryBean.java | 12 +++++------- .../payment/manage/tradelog/beans/TradeLogQuery.java | 8 +++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/beans/AppQueryBean.java b/src/main/java/au/com/royalpay/payment/manage/appclient/beans/AppQueryBean.java index 74fe9b474..3b6f89515 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/beans/AppQueryBean.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/beans/AppQueryBean.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.beans.OrderStatus; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.beans.PayChannel; import au.com.royalpay.payment.tools.defines.TradeType; +import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.time.DateUtils; @@ -34,21 +35,18 @@ public class AppQueryBean { public JSONObject toParams() { JSONObject params = new JSONObject(); - if (timezone != null) { - format.setTimeZone(TimeZone.getTimeZone(timezone)); - } if (begin != null) { try { - params.put("begin", format.parse(begin)); - params.put("from", format.parse(begin)); + params.put("begin", TimeZoneUtils.formatTime(format.parse(begin),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"")); + params.put("from", TimeZoneUtils.formatTime(format.parse(begin),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"")); } catch (ParseException e) { throw new ParamInvalidException("begin", "error.payment.valid.invalid_date_format"); } } if (end != null) { try { - params.put("end", DateUtils.addDays(format.parse(end), 1)); - params.put("to", DateUtils.addDays(format.parse(end), 1)); + params.put("end", TimeZoneUtils.formatTime(DateUtils.addDays(format.parse(end), 1),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"")); + params.put("to", TimeZoneUtils.formatTime(DateUtils.addDays(format.parse(end), 1),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"")); } catch (ParseException e) { throw new ParamInvalidException("end", "error.payment.valid.invalid_date_format"); } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java index 24dc602ed..c7715780c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.beans.OrderStatus; import au.com.royalpay.payment.core.beans.PayChannel; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.tools.defines.TradeType; +import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; @@ -41,19 +42,16 @@ public class TradeLogQuery { public JSONObject toParams(String timezone) { JSONObject params = new JSONObject(); - if (timezone != null) { - format.setTimeZone(TimeZone.getTimeZone(timezone)); - } if (datefrom != null) { try { - params.put("from", format.parse(datefrom)); + params.put("from", TimeZoneUtils.formatTime(format.parse(datefrom),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"")); } catch (ParseException e) { throw new ParamInvalidException("datefrom", "error.payment.valid.invalid_date_format"); } } if (dateto != null) { try { - params.put("to", DateUtils.addDays(format.parse(dateto), 1)); + params.put("to", TimeZoneUtils.formatTime(DateUtils.addDays(format.parse(dateto), 1),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"")); } catch (ParseException e) { throw new ParamInvalidException("dateto", "error.payment.valid.invalid_date_format"); }