From 714cefae2e6134b9d7186ab20a864a3a2f12b0b7 Mon Sep 17 00:00:00 2001 From: liaozan <378024053@qq.com> Date: Tue, 16 May 2023 23:30:16 +0800 Subject: [PATCH] Update IdWorker --- .../java/com/schbrain/common/util/IdWorker.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/commons/common-util/src/main/java/com/schbrain/common/util/IdWorker.java b/commons/common-util/src/main/java/com/schbrain/common/util/IdWorker.java index 174e974..31f0c06 100644 --- a/commons/common-util/src/main/java/com/schbrain/common/util/IdWorker.java +++ b/commons/common-util/src/main/java/com/schbrain/common/util/IdWorker.java @@ -100,12 +100,16 @@ public class IdWorker { /** * get the timestamp (millis second) of id - * - * @param id the nextId - * @return the timestamp of id */ public static long getIdTimestamp(long id) { - return INSTANCE.idEpoch + (id >> timestampLeftShift); + return getIdTimestamp(id, INSTANCE); + } + + /** + * get the timestamp (millis second) of id + */ + public static long getIdTimestamp(long id, IdWorker idWorker) { + return idWorker.idEpoch + (id >> timestampLeftShift); } private synchronized long nextId() { @@ -137,4 +141,4 @@ public class IdWorker { return System.currentTimeMillis(); } -} \ No newline at end of file +} -- GitLab