Android Java - Joda Date is slow in Eclipse/Emulator -

若如初见. 提交于 2019-12-23 19:32:55

问题


I am trying to find a set of date functions. Looks like the Joda

http://www.joda.org/joda-time/

Does everything I need, but when I call a simple

DateTime dt = new DateTime();

it hangs the Eclipse or Emulator for about 15 seconds.

I must be doing something wrong as I haven't found anyone else complaining about it being slow.

Short of the Joda jar anyone had a datediff() code sample?


回答1:


I can confirm this in version 1, 1.5 and 1.62 ... I got bored after that and instead used Date4J which seems to be working perfectly and meets my needs!

http://www.date4j.net/




回答2:


Is there something wrong with just using the java.util.Date()?




回答3:


You can use the Traceview feature, available from the DDMS perspective, to see where the time is going. When you do this, you'll quickly see most of it is initializing the timezone database.

There's more information about some possible workarounds at this other question.

For my application, I knew I would only ever need a few timezones. So, I blanked out the Olson Timezone Database files in the Jodatime source for all the timezones I wasn't using. Then I rebuilt Jodatime.




回答4:


Make sure you are using v1.6.2. There was an Android issue in v1.6 and v1.6.1.



来源:https://stackoverflow.com/questions/4542867/android-java-joda-date-is-slow-in-eclipse-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!