All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.intters.idworker.DayCode Maven / Gradle / Ivy

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());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy