fix format夏時令

master
luoyang 6 years ago
parent afee1234a3
commit baee192105

@ -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.exceptions.ParamInvalidException;
import au.com.royalpay.payment.core.beans.PayChannel; import au.com.royalpay.payment.core.beans.PayChannel;
import au.com.royalpay.payment.tools.defines.TradeType; import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
@ -34,21 +35,18 @@ public class AppQueryBean {
public JSONObject toParams() { public JSONObject toParams() {
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
if (timezone != null) {
format.setTimeZone(TimeZone.getTimeZone(timezone));
}
if (begin != null) { if (begin != null) {
try { try {
params.put("begin", format.parse(begin)); params.put("begin", TimeZoneUtils.formatTime(format.parse(begin),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:""));
params.put("from", format.parse(begin)); params.put("from", TimeZoneUtils.formatTime(format.parse(begin),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:""));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("begin", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("begin", "error.payment.valid.invalid_date_format");
} }
} }
if (end != null) { if (end != null) {
try { try {
params.put("end", 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", DateUtils.addDays(format.parse(end), 1)); params.put("to", TimeZoneUtils.formatTime(DateUtils.addDays(format.parse(end), 1),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:""));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("end", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("end", "error.payment.valid.invalid_date_format");
} }

@ -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.beans.PayChannel;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.tools.defines.TradeType; import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -41,19 +42,16 @@ public class TradeLogQuery {
public JSONObject toParams(String timezone) { public JSONObject toParams(String timezone) {
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
if (timezone != null) {
format.setTimeZone(TimeZone.getTimeZone(timezone));
}
if (datefrom != null) { if (datefrom != null) {
try { 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) { } catch (ParseException e) {
throw new ParamInvalidException("datefrom", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("datefrom", "error.payment.valid.invalid_date_format");
} }
} }
if (dateto != null) { if (dateto != null) {
try { 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) { } catch (ParseException e) {
throw new ParamInvalidException("dateto", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("dateto", "error.payment.valid.invalid_date_format");
} }

Loading…
Cancel
Save