1. 程式人生 > >java自增流水號(日期+隨機數)

java自增流水號(日期+隨機數)

<pre name="code" class="java">/**
	 * @描述 java生成流水號 
	 * 14位時間戳 + 6位隨機數
	 * @作者 shaomy
	 * @時間:2015-1-29 上午10:57:41
	 * @引數:@return 
	 * @返回值:String
	 */
	public String getNumberForPK(){
    	String id="";
    	SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
    	String temp = sf.format(new Date());
		int random=(int) (Math.random()*10000);
		id=temp+random;
		return id;
	}