Skip to content

Commit 2d62068

Browse files
committed
过期时间分钟数不精准问题
1 parent 472b7f6 commit 2d62068

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • pay-java-common/src/main/java/com/egzosn/pay/common/util

pay-java-common/src/main/java/com/egzosn/pay/common/util/DateUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* 日期转换运算工具
1414
*
1515
* @author egan
16-
* <pre>
16+
* <pre>
1717
* email egzosn@gmail.com
1818
* date 2018-11-21 16:43:20
1919
* </pre>
@@ -23,6 +23,7 @@ private DateUtils() {
2323
}
2424

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

@@ -37,7 +38,7 @@ public static SimpleDateFormat formatFor(String pattern) {
3738
THREADLOCAL_FORMATS.set(new SoftReference(formats));
3839
}
3940

40-
SimpleDateFormat format = formats.get(pattern);
41+
SimpleDateFormat format = formats.get(pattern);
4142

4243
if (format == null) {
4344
format = new SimpleDateFormat(pattern);
@@ -66,6 +67,7 @@ public static String formatDate(Date date, String pattern) {
6667
SimpleDateFormat formatFor = DateFormatHolder.formatFor(pattern);
6768
return formatFor.format(date);
6869
}
70+
6971
public static Date parseDate(String date, String pattern) {
7072
Args.notNull(date, "Date");
7173
Args.notNull(pattern, "Pattern");
@@ -77,9 +79,11 @@ public static Date parseDate(String date, String pattern) {
7779
}
7880
return null;
7981
}
82+
8083
public static Date parse(String date) {
8184
return parseDate(date, YYYY_MM_DD_HH_MM_SS);
8285
}
86+
8387
public static final String format(Date date) {
8488
return formatDate(date, YYYY_MM_DD_HH_MM_SS);
8589
}
@@ -99,7 +103,7 @@ public static final String formatDay(Date date) {
99103
* @return 分钟数
100104
*/
101105
public static final long minutesRemaining(Date date) {
102-
return (date.getTime() - System.currentTimeMillis()) / 1000 / 60;
106+
return (date.getTime() / 1000 / 60 - System.currentTimeMillis() / 1000 / 60);
103107
}
104108

105109
/**

0 commit comments

Comments
 (0)