Alex Rivera | Logout

Alternatives to FastDateFormat for efficient date parsing?

Asked 2010-12-27T20:35:05.170
26

Well aware of performance and thread issues with SimpleDateFormat, I decided to go with FastDateFormat, until I realized that FastDateFormat is for formatting only, no parsing!

Is there an alternative to FastDateFormat, that is ready to use out of the box and much faster than SimpleDateFormat?

I believe FastDateFormat is one of the faster ones, so anything that is about as fast would do.

Just curious , any idea why FastDateFormat does not support parsing? Doesn't it seriously limit its use?

Edit
Report

1 Answer

10

Found something interesting here of this case in Android: http://andmob.wikidot.com/faq-simpletimeformat

SimpleDateFormat, the first time you try parsing (or, presumably, formatting) a date, will load in all the timezone data for your locale. This will take 2-3 seconds. It is hoped that this will be fixed in some future edition of Android.

In the interim, consider using AsyncTask to "warm up" SimpleDateFormat in your process before you need it. Just parse some date in the AsyncTask doInBackground() to get it to load the timezones sometime when it will not impact the user so much. Once initialized in your process, SimpleDateFormat will run quickly until your process is terminated.

answered 2011-05-12T18:44:19.720

Your Answer