From 2736ea4edfadf0470184bc001d870657ad424019 Mon Sep 17 00:00:00 2001 From: Hiz Date: Wed, 10 Mar 2021 11:20:06 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E7=A7=BB=E9=99=A4joda-time=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: hiz --- .../mp/api/impl/WxMpKefuServiceImplTest.java | 17 ++++++++++++----- weixin-java-pay/pom.xml | 5 ----- .../v3/auth/AutoUpdateCertificatesVerifier.java | 6 +++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java index 712e88742..aa58427a5 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java @@ -1,9 +1,10 @@ package me.chanjar.weixin.mp.api.impl; import java.io.File; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.Date; -import org.joda.time.DateTime; import org.testng.annotations.*; import com.google.inject.Inject; @@ -169,8 +170,11 @@ public class WxMpKefuServiceImplTest { @Test public void testKfMsgList() throws WxErrorException { - Date startTime = DateTime.now().minusDays(1).toDate(); - Date endTime = DateTime.now().minusDays(0).toDate(); + // Date startTime = DateTime.now().minusDays(1).toDate(); + // Date endTime = DateTime.now().minusDays(0).toDate(); + Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS)); + Date endTime = Date.from(Instant.now()); + WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime, 1L, 50); assertThat(result).isNotNull(); System.err.println(result); @@ -178,8 +182,11 @@ public class WxMpKefuServiceImplTest { @Test public void testKfMsgListAll() throws WxErrorException { - Date startTime = DateTime.now().minusDays(1).toDate(); - Date endTime = DateTime.now().minusDays(0).toDate(); + // Date startTime = DateTime.now().minusDays(1).toDate(); + // Date endTime = DateTime.now().minusDays(0).toDate(); + Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS)); + Date endTime = Date.from(Instant.now()); + WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime); assertThat(result).isNotNull(); System.err.println(result); diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 6435301f1..9867cc7ae 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -73,11 +73,6 @@ com.google.code.gson gson - - joda-time - joda-time - compile - diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java index b49f6251a..d365ccaf4 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java @@ -16,8 +16,8 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; -import org.joda.time.Instant; -import org.joda.time.Minutes; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -110,7 +110,7 @@ public class AutoUpdateCertificatesVerifier implements Verifier { * 检查证书是否在有效期内,如果不在有效期内则进行更新 */ private void checkAndAutoUpdateCert() { - if (instant == null || Minutes.minutesBetween(instant, Instant.now()).getMinutes() >= minutesInterval) { + if (instant == null || instant.plus(minutesInterval, ChronoUnit.MINUTES).compareTo(Instant.now()) >= 0) { if (lock.tryLock()) { try { autoUpdateCert();