Java tutorial
//package com.java2s; import java.util.Random; public class Main { public synchronized static Long createId() { int max = 999; int min = 100; Random random = new Random(); Integer s = random.nextInt(max) % (max - min + 1) + min; Long currentTimeMillis = System.currentTimeMillis(); return Long.parseLong(currentTimeMillis.toString() + s.toString()); } }