解析许多项目的日期 [英] Parsing many Date items
本文介绍了解析许多项目的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有很多的日期字符串,如周五,2011年4月8日22时28分00秒-0400列表,需要将其解析到一个正确的格式(星期五,2011年4月08)。
我的问题是,该设备需要有非常非常长的时间解析> 10 Date对象,偶尔耗尽内存。有没有更有效的方式解析日期为:
I have a list with many Date Strings such as "Fri, 08 Apr 2011 22:28:00 -0400" and need to parse them to a proper format (Friday, 08. April 2011). My problem is that the device needs a very very long time parsing > 10 date objects and occasionally runs out of memory. Is there a more efficient way parsing dates as:
SimpleDateFormat sdf = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
// later in code
try {
Date date = sdf.parse(myDateString);
return DateFormat.format("dd. MMMM yyyy", date).toString();
} catch (java.text.ParseException e) {
}
我怎么能解析很多日期字符串非常快?
How can I parse many date Strings very fast?
推荐答案
如果可能的话,这个任务分配给你的数据库(假设SQLite的),看看是否其的日期和时间功能是有用你的情况。
If possible, assign this task to your database (assuming SQLite) and see if its Date and Time function are useful in your case.
这篇关于解析许多项目的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文