🎨 移除joda-time依赖

Co-authored-by: hiz <liang@0318>
This commit is contained in:
Hiz
2021-03-10 11:20:06 +08:00
committed by GitHub
parent 30155b316b
commit 2736ea4edf
3 changed files with 15 additions and 13 deletions

View File

@ -1,9 +1,10 @@
package me.chanjar.weixin.mp.api.impl; package me.chanjar.weixin.mp.api.impl;
import java.io.File; import java.io.File;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import org.joda.time.DateTime;
import org.testng.annotations.*; import org.testng.annotations.*;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -169,8 +170,11 @@ public class WxMpKefuServiceImplTest {
@Test @Test
public void testKfMsgList() throws WxErrorException { public void testKfMsgList() throws WxErrorException {
Date startTime = DateTime.now().minusDays(1).toDate(); // Date startTime = DateTime.now().minusDays(1).toDate();
Date endTime = DateTime.now().minusDays(0).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); WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime, 1L, 50);
assertThat(result).isNotNull(); assertThat(result).isNotNull();
System.err.println(result); System.err.println(result);
@ -178,8 +182,11 @@ public class WxMpKefuServiceImplTest {
@Test @Test
public void testKfMsgListAll() throws WxErrorException { public void testKfMsgListAll() throws WxErrorException {
Date startTime = DateTime.now().minusDays(1).toDate(); // Date startTime = DateTime.now().minusDays(1).toDate();
Date endTime = DateTime.now().minusDays(0).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); WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime);
assertThat(result).isNotNull(); assertThat(result).isNotNull();
System.err.println(result); System.err.println(result);

View File

@ -73,11 +73,6 @@
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
</dependency> </dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>

View File

@ -16,8 +16,8 @@ import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.joda.time.Instant; import java.time.Instant;
import org.joda.time.Minutes; import java.time.temporal.ChronoUnit;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
@ -110,7 +110,7 @@ public class AutoUpdateCertificatesVerifier implements Verifier {
* 检查证书是否在有效期内,如果不在有效期内则进行更新 * 检查证书是否在有效期内,如果不在有效期内则进行更新
*/ */
private void checkAndAutoUpdateCert() { 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()) { if (lock.tryLock()) {
try { try {
autoUpdateCert(); autoUpdateCert();