之前使用的
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()
到底是不是呢?懶得試了