com.intters.idworker.DayCode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of - Show documentation
Show all versions of - Show documentation
Rapid development tool class
The newest version!
package com.intters.idworker;
import com.intters.idworker.strategy.DayPrefixRandomCodeStrategy;
public class DayCode {
static RandomCodeStrategy strategy;
static {
DayPrefixRandomCodeStrategy dayPrefixCodeStrategy = new DayPrefixRandomCodeStrategy("yyMM");
dayPrefixCodeStrategy.setMinRandomSize(7);
dayPrefixCodeStrategy.setMaxRandomSize(7);
strategy = dayPrefixCodeStrategy;
strategy.init();
}
public static synchronized String next() {
return String.format("%d-%04d-%07d", Id.getWorkerId(), strategy.prefix(), strategy.next());
}
}