Skip to content

Commit 2736ea4

Browse files
hizlinhiz
andauthored
🎨 移除joda-time依赖
Co-authored-by: hiz <liang@0318>
1 parent 30155b3 commit 2736ea4

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package me.chanjar.weixin.mp.api.impl;
22

33
import java.io.File;
4+
import java.time.Instant;
5+
import java.time.temporal.ChronoUnit;
46
import java.util.Date;
57

6-
import org.joda.time.DateTime;
78
import org.testng.annotations.*;
89

910
import com.google.inject.Inject;
@@ -169,17 +170,23 @@ public void testKfSessionGetWaitCase() throws WxErrorException {
169170

170171
@Test
171172
public void testKfMsgList() throws WxErrorException {
172-
Date startTime = DateTime.now().minusDays(1).toDate();
173-
Date endTime = DateTime.now().minusDays(0).toDate();
173+
// Date startTime = DateTime.now().minusDays(1).toDate();
174+
// Date endTime = DateTime.now().minusDays(0).toDate();
175+
Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
176+
Date endTime = Date.from(Instant.now());
177+
174178
WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime, 1L, 50);
175179
assertThat(result).isNotNull();
176180
System.err.println(result);
177181
}
178182

179183
@Test
180184
public void testKfMsgListAll() throws WxErrorException {
181-
Date startTime = DateTime.now().minusDays(1).toDate();
182-
Date endTime = DateTime.now().minusDays(0).toDate();
185+
// Date startTime = DateTime.now().minusDays(1).toDate();
186+
// Date endTime = DateTime.now().minusDays(0).toDate();
187+
Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
188+
Date endTime = Date.from(Instant.now());
189+
183190
WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime);
184191
assertThat(result).isNotNull();
185192
System.err.println(result);

weixin-java-pay/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@
7373
<groupId>com.google.code.gson</groupId>
7474
<artifactId>gson</artifactId>
7575
</dependency>
76-
<dependency>
77-
<groupId>joda-time</groupId>
78-
<artifactId>joda-time</artifactId>
79-
<scope>compile</scope>
80-
</dependency>
8176
</dependencies>
8277

8378
<profiles>

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import org.apache.http.client.methods.HttpGet;
1717
import org.apache.http.impl.client.CloseableHttpClient;
1818
import org.apache.http.util.EntityUtils;
19-
import org.joda.time.Instant;
20-
import org.joda.time.Minutes;
19+
import java.time.Instant;
20+
import java.time.temporal.ChronoUnit;
2121

2222
import java.io.ByteArrayInputStream;
2323
import java.io.IOException;
@@ -110,7 +110,7 @@ public boolean verify(String serialNumber, byte[] message, String signature) {
110110
* 检查证书是否在有效期内,如果不在有效期内则进行更新
111111
*/
112112
private void checkAndAutoUpdateCert() {
113-
if (instant == null || Minutes.minutesBetween(instant, Instant.now()).getMinutes() >= minutesInterval) {
113+
if (instant == null || instant.plus(minutesInterval, ChronoUnit.MINUTES).compareTo(Instant.now()) >= 0) {
114114
if (lock.tryLock()) {
115115
try {
116116
autoUpdateCert();

0 commit comments

Comments
 (0)