API其他函數 ,system date,..

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);  //向左偏移一天




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章