Skip to content

Commit

Permalink
🎨 移除joda-time依赖
Browse files Browse the repository at this point in the history
Co-authored-by: hiz <liang@0318>
  • Loading branch information
hizlin and hiz authored Mar 10, 2021
1 parent 30155b3 commit 2736ea4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -169,17 +170,23 @@ public void testKfSessionGetWaitCase() throws WxErrorException {

@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);
}

@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);
Expand Down
5 changes: 0 additions & 5 deletions weixin-java-pay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
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;
Expand Down Expand Up @@ -110,7 +110,7 @@ public boolean verify(String serialNumber, byte[] message, String signature) {
* 检查证书是否在有效期内,如果不在有效期内则进行更新
*/
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();
Expand Down

0 comments on commit 2736ea4

Please sign in to comment.