refactor(devkit-utils): Optimised the time zone for getting current timestamp.

This commit is contained in:
Zihlu Wang
2023-09-18 10:01:27 +08:00
parent 09c973dde4
commit 007d192b01
@@ -20,6 +20,7 @@ package cn.org.codecrafters.guid;
import cn.org.codecrafters.guid.exceptions.TimingException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
/**
@@ -203,7 +204,7 @@ public final class SnowflakeGuidCreator implements GuidCreator<Long> {
* @return the current timestamp
*/
private long currentTimestamp() {
return LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli();
return LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
}