Android獲取當前時間的android.text.format.Time已過時

之前使用的

Time time = new android.text.format.Time();
time.setToNow();
String timeNow = time.format("%Y%m%d%H%M%S");

來獲取當前時間,但是在android22中提示過時 deprecated

然後找了下,實在不知道用哪個好,只好試試這個

Calendar calendar = Calendar.getInstance();
String timeNow = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());

還好,暫時沒發現問題.

不過剛看到一篇文章

http://tangmingjie2009.iteye.com/blog/1543166

說是用這個方法是最慢的.最快的是

System.currentTimeMillis()

到底是不是呢?懶得試了

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