mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-08 03:56:48 +08:00
优化日期
This commit is contained in:
@@ -9,6 +9,7 @@ import com.egzosn.pay.common.bean.result.PayException;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import com.egzosn.pay.common.http.HttpConfigStorage;
|
||||
import com.egzosn.pay.common.http.UriVariables;
|
||||
import com.egzosn.pay.common.util.DateUtils;
|
||||
import com.egzosn.pay.common.util.MatrixToImageWriter;
|
||||
import com.egzosn.pay.common.util.sign.SignUtils;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
@@ -200,7 +201,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
}
|
||||
}
|
||||
if (null != order.getExpirationTime()) {
|
||||
bizContent.put("timeout_express", ((order.getExpirationTime().getTime() - System.currentTimeMillis()) / 1000 / 60 + "m"));
|
||||
bizContent.put("timeout_express", DateUtils.minutesRemaining(order.getExpirationTime()) + "m");
|
||||
}
|
||||
orderInfo.put("biz_content", JSON.toJSONString(bizContent));
|
||||
return orderInfo;
|
||||
@@ -217,9 +218,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
orderInfo.put("app_id", payConfigStorage.getAppid());
|
||||
orderInfo.put("method", transactionType.getMethod());
|
||||
orderInfo.put("charset", payConfigStorage.getInputCharset());
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
df.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
orderInfo.put("timestamp", df.format(new Date()));
|
||||
orderInfo.put("timestamp", DateUtils.format(new Date()));
|
||||
orderInfo.put("version", "1.0");
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.egzosn.pay.common.util;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* 日期转换运算工具
|
||||
* @author egan
|
||||
* <pre>
|
||||
* email egzosn@gmail.com
|
||||
* date 2018-11-21 16:43:20
|
||||
* </pre>
|
||||
*/
|
||||
public final class DateUtils {
|
||||
public static final DateFormat YYYY_MM_DD_HH_MM_SS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
public static final DateFormat YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
static {
|
||||
YYYY_MM_DD_HH_MM_SS.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
YYYY_MM_DD.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
}
|
||||
|
||||
public static final String format(Date date){
|
||||
return YYYY_MM_DD_HH_MM_SS.format(date);
|
||||
}
|
||||
|
||||
public static final String formatDay(Date date){
|
||||
return YYYY_MM_DD.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余分钟数
|
||||
* @param date 结束点日期
|
||||
* @return 分钟数
|
||||
*/
|
||||
public static final long minutesRemaining(Date date){
|
||||
return (date.getTime() - System.currentTimeMillis()) / 1000 / 60 ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余小时
|
||||
* @param date 结束点日期
|
||||
* @return 小时数
|
||||
*/
|
||||
public static final long remainingHours(Date date){
|
||||
return minutesRemaining(date) / 60 ;
|
||||
}
|
||||
/**
|
||||
* 剩余天数
|
||||
* @param date 结束点日期
|
||||
* @return 天数
|
||||
*/
|
||||
public static final long remainingDays(Date date){
|
||||
return remainingHours(date) / 24 ;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user