API其他函数 ,system date,..

来源:互联网 发布:echo linux 写入文件 编辑:程序博客网 时间:2024/04/30 10:30

System:
  out:标准输出流,默认的对应设备是显示器
  int: 标准输入流,默认设备是键盘
 
 System.getProperties(); 获取到的系统信息存储到Properties键值集合中
 
 Properties prop =System.getProperties();
Set<String> keySet=prop.stringPropertyName();

****Runtime 就是单例设计模式的对象

Runtime r= Runtime.getRuntime();
r.exec("winmine.exe");

****Math******

 int d=(int)Math.ceil(Math.random()*6); // 1~6

日期的格式化:
   想要把日期按照我们的习惯格式化一下,找到了DateFormat
 Date date = new Date()
// 通过DateFormat 类的静态工厂方法获取实例

 DateFormat dateFormat= DateFormat.getDateInstance(DateFormat.Full);
;

 // 转成自定义格式,xxx/xx/xx ,自定义对象,只有子类
dateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");

//使用DateFormate的format 方法对日期对象进行格式化。//将日期对象转成日期格式的字符串

 String str_date =dateFormat.format(date);
 c.set(Calender.YEAR,2014);
 c.set(2014,2,1);
 c.add(Calendar.DAY_OF_MONTH,-1);  //向左偏移一天




0 0