Parsing RSS pubDate in Android slow with SimpleDateFormat

812 views Asked by At

I need to parse pubDate from RSS feeds in an Android App. Unfortunately, the pubDate is formatted differently in different RSS feeds (e.g. EEE, dd MMM yyyy HH:mm:ss z, yyyy-MM-dd'T'HH:mm:ss.SSSz...)

I have found a solution to parse most different date formats with the DateParser.java which uses SimpleDateFormat. However, this implementation is really slow since it does not cache the SimpleDateFormat instances (as recommended for example here).

Any ideas how I can parse all possible date formats faster and avoid reinventing the wheel? Thanks for your input.

1

There are 1 answers

0
jeff_bordon On BEST ANSWER

A fixed DateParser.java can be found here. Here is how the problem was fixed by the contributor:

I modified com.sun.syndication.io.impl.DateParser to use a cache with a limited size for keeping existing SimpleDateFormat objects and will clone them when needed to avoid using constructor method.