Android的负载时区时间过长:为EN_US加载时区名称 [英] Android load timezone too long: Loaded time zone names for en_US
问题描述
亲爱的,我只是codeA片断code获取日期时间字符串,如下:
公共静态字符串getCurrentDate(){
Locale.setDefault(Locale.US);
日期日期=新的日期();
串strDate =与Date.toString();
返回strDate;
}
但问题是,它需要太长时间(约2秒),将日期转换为字符串,日志:
10-11 17:52:51.733:信息/资源(6835):加载时区EN_US在2107ms名。
您能给我一个解决方案,如何提高这种方法的性能
更新的解决方案: 我刚刚发现tronman在议题的解决方案: <一href="http://stackoverflow.com/questions/454315/how-do-you-format-date-and-time-in-android">http://stackoverflow.com/questions/454315/how-do-you-format-date-and-time-in-android 如下:
日期日期=新的日期();
java.text.DateFormat中DATEFORMAT =
android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText(时间:+ dateFormat.format(日期));
另一种解决方案是使用的SimpleDateFormat
与默认语言环境
新的SimpleDateFormat(DD / MM,Locale.getDefault());
Dear all, i just code a snippet code to get date time string as below:
public static String getCurrentDate(){
Locale.setDefault(Locale.US);
Date date = new Date();
String strDate = date.toString();
return strDate;
}
But problem is it take too long time (about 2 seconds) to convert from Date to string, Logs:
10-11 17:52:51.733: INFO/Resources(6835): Loaded time zone names for en_US in 2107ms.
Could you please give me a solution how to increase performance of this method
Update for solution: I just found an solution by tronman at topic: http://stackoverflow.com/questions/454315/how-do-you-format-date-and-time-in-android As below:
Date date = new Date();
java.text.DateFormat dateFormat =
android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText("Time: " + dateFormat.format(date));
Yet another solution is to use SimpleDateFormat
with default locale
new SimpleDateFormat("dd/MM", Locale.getDefault());
这篇关于Android的负载时区时间过长:为EN_US加载时区名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!