日期:2014-05-20 浏览次数:20594 次
public class Test { public static void main(String[] args) { Date date1 = new Date(); long time1 = date1.getTime() * 10000; double ran1 = Math.random() * 10000; String firstString = Double.toString(time1 + ran1); System.out.println(firstString); Date date2 = new Date(); long time2 = date2.getTime() * 10000; double ran2 = Math.random() * 10000; String secondString = Double.toString(time2 + ran2); System.out.println(secondString); String finalString = firstString + secondString; System.out.println(finalString.substring(0, 11)); } }
------解决方案--------------------
ding
------解决方案--------------------
public static void main(String[] args) { // TODO Auto-generated method stub Random rd = new Random(); System.out.println((Long.toString(new Date().getTime()*10000+rd.nextInt(1)*10000,32)+Long.toString(new Date().getTime()*10000+rd.nextInt(1)*10000,32)).substring(0,11)); }
------解决方案--------------------
new Date().getTime() =》 System.currentMillions()
Math.random(1) => rd.nextInt(1)
substr =》 substring()
基本就这3个
------解决方案--------------------
------解决方案--------------------
主要就是javascript的
new Date().getTime().toString(32)
------解决方案--------------------