Commit 714cefae authored by liaozan's avatar liaozan 🏀

Update IdWorker

parent a5035bdb
...@@ -100,12 +100,16 @@ public class IdWorker { ...@@ -100,12 +100,16 @@ public class IdWorker {
/** /**
* get the timestamp (millis second) of id * get the timestamp (millis second) of id
*
* @param id the nextId
* @return the timestamp of id
*/ */
public static long getIdTimestamp(long 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() { private synchronized long nextId() {
...@@ -137,4 +141,4 @@ public class IdWorker { ...@@ -137,4 +141,4 @@ public class IdWorker {
return System.currentTimeMillis(); return System.currentTimeMillis();
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment