spring-attic / spring-social-twitter

Twitter API binding and connect support.
http://projects.spring.io/spring-social-twitter
Apache License 2.0
122 stars 115 forks source link

SimpleDateFormat performance problem #58

Open agrebnev opened 11 years ago

agrebnev commented 11 years ago

It looks like in the class org.springframework.social.twitter.api.impl.TweetDeserializer

and method public Tweet deserialize(JsonNode node) SimpleDateFormat is created for every node. I leads performance problems. As I can see the dateFormat is a constant TIMELINE_DATE_FORMAT so we can make dateFormat static and reuse it.

I have found similar problems in some other places in Tweeter code. Please check all places where SimpleDateFormat is used.

This problem is very serious in case of using in Android because of its issue described in the following topics https://code.google.com/p/android/issues/detail?id=3147 https://code.google.com/p/android-rome-feed-reader/issues/detail?id=1 http://stackoverflow.com/questions/3905545/android-load-timezone-too-long-loaded-time-zone-names-for-en-us http://stackoverflow.com/questions/454315/how-do-you-format-date-and-time-in-android

Every using of SimpleDateFormat lead to whole ONE SECOND delay in Android. The best will be not using SimpleDateFormat at all as it is done in Spring Social Facebook.

Hacko-nPacko commented 10 years ago

just some considerations when using a shared SDF: http://stackoverflow.com/questions/5652518/confusion-about-thread-safety-simpledateformat-example