标签:时间 time 获取 class .text rac and tac ring
将写内容过程中重要的一些内容做个记录,如下资料是关于java获取随机时间的片段的内容。import java.text.parseexception;
import java.text.simpledateformat;
import java.util.date;
public class getrandomtiem {
public static void main(string []args){
simpledateformat format = new simpledateformat("hh:mm:ss");
date randomdate=randomdate("00:00:00","24:59:59");
string randomdats="shi"+randomdate.gethours()+"f"+randomdate.getminutes()+"m"+randomdate.getseconds();
system.out.println(randomdats);
}
private static date randomdate(string begindate,string enddate ){
try {
simpledateformat format = new simpledateformat("hh:mm:ss");
if(start.gettime() >= end.gettime()){
return null;
}
long date = random(start.gettime(),end.gettime());
return new date(date);
} catch (exception e) {
e.printstacktrace();
}
return null;
}
private static long random(long begin,long end){
if(rtn == begin || rtn == end){
return random(begin,end);
}
return rtn;
}
}
标签:时间 time 获取 class .text rac and tac ring
原文地址:https://blog.51cto.com/14147980/2395417