package org.springblade.common.utils;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.atomic.AtomicInteger;

public class GenerateNum {
	//19位
	private static final AtomicInteger SEQ = new AtomicInteger();
	private static final DateTimeFormatter DF_FMT_PREFIX = DateTimeFormatter.ofPattern("yyMMddHHmmssSS");
	private static ZoneId ZONE_ID = ZoneId.of("Asia/Shanghai");

	public static String generateNum(){
		LocalDateTime dateTime = LocalDateTime.now(ZONE_ID);
		if(SEQ.intValue()>9990){
			SEQ.getAndSet(1000);
		}
		return dateTime.format(DF_FMT_PREFIX)+SEQ.getAndIncrement();
	}
}
