4
時區名稱
親愛的,我只是一個代碼段的代碼來獲得如下日期時間字符串:Android的負載時區時間過長:加載EN_US
public static String getCurrentDate(){
Locale.setDefault(Locale.US);
Date date = new Date();
String strDate = date.toString();
return strDate;
}
但問題是,它要花很長的時間(約2秒),將日期轉換爲字符串,日誌:
10-11 17:52:51.733: INFO/Resources(6835): Loaded time zone names for en_US in 2107ms.
您能給我一個解決方案如何提高這種方法
更新解決方案的性能: 我剛剛發現tronman在話題的解決方案: How do you format date and time in Android? 如下:
Date date = new Date();
java.text.DateFormat dateFormat =
android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText("Time: " + dateFormat.format(date));
重複question/8881142/simpledateformat-too-long-when-the-time-zone-is-included – Somatik 2012-08-18 15:16:59
如果您有答案,爲什麼不單獨發佈它並將其標記爲接受答案? – Kuitsi 2013-02-22 14:30:05