import java.sql.Timestamp; import java.util.Random; public class OrderIdBuilder { public static String createOrderId(){ Random ran = new Random(); Timestamp t = new Timestamp(System.currentTimeMillis()); String orderId = t.toString().replaceAll("-", "").replaceAll(":", "").replace('.', ' ').replaceAll(" ", "").trim(); for(int i=0; i<5; i++){ int data = ran.nextInt(10); orderId = orderId + data; } return orderId; } }