<a href="http://www.itheima.com" target="blank">android培训</a>、<a href="http://www.itheima.com" target="blank">java培训</a>
(1) Date类
Date d=new Date();
SimpleDateFormat sdf=new SimpleDateFormat
(yyyy年MM月dd日E——HH时mm分ss秒);
sdf.format(d);
(2) Calendar类
Calendar c=Calendar.getInstance();
c.get(Calendar.Year);//获取年
c.get(Calendar.Month);//获取月
c.get(Calendar.DayofMonth);//获取日
c.get(Calendar.DayofWeek);//获取星期
Date d=Calendar.getTime();
(3) Random类
Random r=new Random();
r.nextInt(1);//零到一之间的随机数,不含一,含零
Double d=Math.random();//零到一之间的随机数,不含一,含零
(4) Runtime类
单例设计模式
Runtime r=Runtime.getRuntime();
Proccess p=r.exec(“某路径下的文件”);
p.destory();
(5) System类
方法都是静态的
Properties ps=System.getProperties();//获取当前系统属性,HashTable
System.setProperty("mykey","myvalue");//自定义系统某个属性