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

com.tmsps.ne4spring.utils.PKUtil Maven / Gradle / Ivy

There is a newer version: 999.0.0.0
Show newest version
/**
 * 2015年6月17日上午11:46:08   2015
 * @author zhangwei  [email protected]
 * @Description: 
 */
package com.tmsps.ne4spring.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang3.RandomStringUtils;

/**
 * 
 * @author zhangwei [email protected]
 *
 */
public class PKUtil {
	/**
	 *======================================================
	 * @author zhangwei [email protected] 
	 *------------------------------------------------------
	 * 主要用户生产代理主键(PK)使用
	 *======================================================
	 */
	public static String getPK() {
		return GenerateUtil.getBase58ID();
	}
	
	public static long getPKL() {
		return GenerateLongUtil.getInstance().nextId();
	}
	
	//返回类似201603181601064663899883390订单号
	public static String getOrderNO(){
		return getOrderNO("yyyyMMddHHmmssSSS",10);
	}
	
	public synchronized static String getOrderNO(String datePartten,int randomNumeric) {
		try {
			Thread.sleep(1);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		SimpleDateFormat sd = new SimpleDateFormat(datePartten);
		return sd.format(new Date()) + RandomStringUtils.randomNumeric(randomNumeric);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy