From 99b6e14ff7af785153907deaf6ff85e6cdfa343e Mon Sep 17 00:00:00 2001 From: LamGC Date: Tue, 5 May 2020 17:09:45 +0800 Subject: [PATCH] =?UTF-8?q?[Change]=20RandomIntervalSendTimer=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=E5=86=85=E5=AE=B9?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/lamgc/cgj/bot/RandomIntervalSendTimer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/lamgc/cgj/bot/RandomIntervalSendTimer.java b/src/main/java/net/lamgc/cgj/bot/RandomIntervalSendTimer.java index 693ce69..53e7e32 100644 --- a/src/main/java/net/lamgc/cgj/bot/RandomIntervalSendTimer.java +++ b/src/main/java/net/lamgc/cgj/bot/RandomIntervalSendTimer.java @@ -5,8 +5,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.reflect.Field; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; @@ -26,6 +24,8 @@ public class RandomIntervalSendTimer extends TimerTask { private final int floatTime; private AtomicBoolean loop = new AtomicBoolean(); private final AtomicBoolean start = new AtomicBoolean(); + private final String hashId = Integer.toHexString(this.hashCode()); + /** * 创建一个随机延迟发送器 @@ -92,8 +92,6 @@ public class RandomIntervalSendTimer extends TimerTask { start(this.loop.get()); } - private final static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-ss HH:mm:ss"); - /** * 启动定时器 * @param loop 是否循环, 如果为true, 则任务完成后会自动调用start方法继续循环, 直到被调用{@code #}或总定时器被销毁; @@ -103,7 +101,7 @@ public class RandomIntervalSendTimer extends TimerTask { long nextDelay = time + timeRandom.nextInt(floatTime); Date nextDate = new Date(); nextDate.setTime(nextDate.getTime() + nextDelay); - log.info("定时器 {} 下一延迟: {}ms ({})", Integer.toHexString(this.hashCode()), nextDelay, dateFormat.format(nextDate)); + log.info("定时器 {} 下一延迟: {}ms ({})", hashId, nextDelay, nextDate); if(start.get()) { try { Field state = this.getClass().getSuperclass().getDeclaredField("state");