<NME> DateUtils.java
<BEF> package com.egzosn.pay.common.util;

import java.lang.ref.SoftReference;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

import org.apache.http.util.Args;
import org.slf4j.Logger;
 * 日期转换运算工具
 *
 * @author egan
 *         <pre>
 *         email egzosn@gmail.com
 *         date 2018-11-21 16:43:20
 *         </pre>
 *         email egzosn@gmail.com
 *         date 2018-11-21 16:43:20
 *         </pre>
    }

    private static final Log LOG = LogFactory.getLog(DateUtils.class);
    static final class DateFormatHolder {
        private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>> THREADLOCAL_FORMATS = new ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>();

    static final class DateFormatHolder {
        private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>> THREADLOCAL_FORMATS = new ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>();

        DateFormatHolder() {
        }

        public static SimpleDateFormat formatFor(String pattern) {
            SoftReference<Map<String, SimpleDateFormat>> ref = THREADLOCAL_FORMATS.get();
                THREADLOCAL_FORMATS.set(new SoftReference(formats));
            }

            SimpleDateFormat format =  formats.get(pattern);

            if (format == null) {
                format = new SimpleDateFormat(pattern);

            if (format == null) {
                format = new SimpleDateFormat(pattern);
                format.setTimeZone(TimeZone.getTimeZone("GMT+8"));
                ((Map) formats).put(pattern, format);
            }

            return format;
        }

        public static void clearThreadLocal() {
            THREADLOCAL_FORMATS.remove();
        }
    }

    public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
    public static final String YYYY_MM_DD_T_HH_MM_SS_SSSXXX = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
    public static final String YYYY_MM_DD_T_HH_MM_SS_XX = "yyyy-MM-dd'T'HH:mm:ssXXX";
    public static final String YYYY_MM_DD = "yyyy-MM-dd";
    public static final String YYYYMMDD = "yyyyMMdd";
    public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
    public static final String MMDD = "MMdd";
        SimpleDateFormat formatFor = DateFormatHolder.formatFor(pattern);
        return formatFor.format(date);
    }
    public static Date parseDate(String date, String pattern) {
        Args.notNull(date, "Date");
        Args.notNull(pattern, "Pattern");
        SimpleDateFormat formatFor = DateFormatHolder.formatFor(pattern);
        return formatFor.format(date);
    }

    public static Date parseDate(String date, String pattern) {
        }
        return null;
    }
    public static Date parse(String date) {
        return parseDate(date, YYYY_MM_DD_HH_MM_SS);
    }
    public static final String format(Date date) {
        return formatDate(date, YYYY_MM_DD_HH_MM_SS);
    }

    public static Date parse(String date) {
        return parseDate(date, YYYY_MM_DD_HH_MM_SS);
    }

    public static String format(Date date) {
        return formatDate(date, YYYY_MM_DD_HH_MM_SS);
    }

    public static Date parseDay(String date) {
        return parseDate(date, YYYY_MM_DD);
    }

     * @return 分钟数
     */
    public static final long minutesRemaining(Date date) {
        return (date.getTime() - System.currentTimeMillis()) / 1000 / 60;
    }

    /**
     * @param date 结束点日期
     * @return 分钟数
     */
    public static long minutesRemaining(Date date) {
        return (date.getTime() / 1000 / 60 - DateUtils.toEpochSecond() / 60);
    }

    /**
     * 剩余小时
     *
     * @param date 结束点日期
     * @return 小时数
     */
    public static long remainingHours(Date date) {
        return minutesRemaining(date) / 60;
    }

    /**
     * 剩余天数
     *
     * @param date 结束点日期
     * @return 天数
     */
    public static long remainingDays(Date date) {
        return remainingHours(date) / 24;
    }

    /**
     * 将此日期时间转换为从epoch开始的秒数
     *
     * @return epoch开始的秒数
     */
    public static long toEpochSecond() {
        return System.currentTimeMillis() / 1000;
    }


}

<MSG> 修复支付订单过期时间不精准问题

<DFF> @@ -13,7 +13,7 @@ import java.util.*;
  * 日期转换运算工具
  *
  * @author egan
- *         <pre>
+ * <pre>
  *         email egzosn@gmail.com
  *         date 2018-11-21 16:43:20
  *         </pre>
@@ -23,6 +23,7 @@ public final class DateUtils {
     }
 
     private static final Log LOG = LogFactory.getLog(DateUtils.class);
+
     static final class DateFormatHolder {
         private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>> THREADLOCAL_FORMATS = new ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>();
 
@@ -37,7 +38,7 @@ public final class DateUtils {
                 THREADLOCAL_FORMATS.set(new SoftReference(formats));
             }
 
-            SimpleDateFormat format =  formats.get(pattern);
+            SimpleDateFormat format = formats.get(pattern);
 
             if (format == null) {
                 format = new SimpleDateFormat(pattern);
@@ -66,6 +67,7 @@ public final class DateUtils {
         SimpleDateFormat formatFor = DateFormatHolder.formatFor(pattern);
         return formatFor.format(date);
     }
+
     public static Date parseDate(String date, String pattern) {
         Args.notNull(date, "Date");
         Args.notNull(pattern, "Pattern");
@@ -77,9 +79,11 @@ public final class DateUtils {
         }
         return null;
     }
+
     public static Date parse(String date) {
         return parseDate(date, YYYY_MM_DD_HH_MM_SS);
     }
+
     public static final String format(Date date) {
         return formatDate(date, YYYY_MM_DD_HH_MM_SS);
     }
@@ -99,7 +103,7 @@ public final class DateUtils {
      * @return 分钟数
      */
     public static final long minutesRemaining(Date date) {
-        return (date.getTime() - System.currentTimeMillis()) / 1000 / 60;
+        return (date.getTime() / 1000 / 60 - System.currentTimeMillis() / 1000 / 60);
     }
 
     /**

修复支付订单过期时间不精准问题