文件上传或下载或许会用到,生成时间的随机数。
例:文件名+"_"+()+扩展名。(TimeStamp ts = new TimeStamp())
import ;
import ;
import ;
public class TimeStamp
{
private SimpleDateFormat sdf = null;
public String getTimeRand()
{
StringBuffer buf = new StringBuffer();
(getTimeStamp());
Random r = new Random();
for (int i = 0; i < 3; i++) {
((10));
}
return ();
}
public String getDate() {
= new SimpleDateFormat("yyyy-MM-dd HH:mm:");
return (new Date());
}
public String getTimeStamp() {
= new SimpleDateFormat("yyyyMMddHHmmssSSS");
return (new Date());
}
}