订单生成类,个人经验总结!
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; } }
What a meaningless sense if losing myself,though owning all of the world.