v2.9.0 & PasswordPolicyValidator

This commit is contained in:
MaxKey
2021-08-09 17:13:19 +08:00
parent 7485cfb236
commit a769cc58f3
8 changed files with 95 additions and 56 deletions

View File

@@ -110,6 +110,17 @@ public class SnowFlakeId {
| machineId << MACHINE_LEFT //机器标识部分
| sequence; //序列号部分
}
public long currId() {
long currStmp = lastStmp;
return (currStmp - START_STMP) << TIMESTMP_LEFT //时间戳部分
| datacenterId << DATACENTER_LEFT //数据中心部分
| machineId << MACHINE_LEFT //机器标识部分
| sequence; //序列号部分
}
private long getNextMill() {
long mill = getNewstmp();

View File

@@ -17,6 +17,7 @@
package org.maxkey.util;
import org.joda.time.DateTime;
import org.junit.Test;
public class SonwFlakeIdTest {
@@ -24,9 +25,12 @@ public class SonwFlakeIdTest {
@Test
public void UidGenerator() {
SnowFlakeId snowFlake = new SnowFlakeId(2, 3);
DateTime d= new DateTime("2020-01-01T01:01:01");
System.out.println("time "+d.getMillis());
SnowFlakeId snowFlake = new SnowFlakeId(1, 1,8,d.getMillis());
long seq = snowFlake.nextId();
System.out.println(seq);
System.out.println(snowFlake.parse(seq));
System.out.println(snowFlake.parse(seq).getDateTime());
}
}