取得系統時間(Calendar)


使用 Calendar 取得系統時間, getInstance() 取得實體,使用 get() 傳入想顯示的資料

   1:  Calendar cal = Calendar.getInstance();
   2:  String dateStr = ""+cal.get(Calendar.YEAR) //2012
   3:  +"/"+(cal.get(Calendar.MONTH)+1) //11 (add 1 because it start from 0)
   4:  +"/"+cal.get(Calendar.DATE);//13
   5:  //Calendar.xxx more date


結果如下






0 意見:

張貼留言

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews