Android Java - Joda日期在Eclipse/模拟器中很慢

时间:2021-08-10 01:29:35

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

我正在寻找一组日期函数。看起来像是Joda

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

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.

它将Eclipse或模拟器挂起大约15秒。

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?

没有Joda jar,有人有datediff()代码示例吗?

4 个解决方案

#1


2  

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!

我可以在版本1,1.5和1.62中确认这一点……在那之后,我感到厌烦了,转而使用Date4J,它看起来工作得很好,满足了我的需要!

http://www.date4j.net/

http://www.date4j.net/

#2


0  

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

仅仅使用java.util.Date()有什么问题吗?

#3


0  

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.

您可以使用来自DDMS透视图的Traceview特性来查看时间的走向。当您这样做时,您将很快看到它的大部分正在初始化时区数据库。

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.

对于我的申请,我知道我只需要几个时区。因此,我在Jodatime源中删除了Olson时区数据库文件,因为我没有使用所有时区。然后我Jodatime重建。

#4


-1  

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

确保您正在使用v1.6.2。在v1.6和v1.6.1中有一个Android问题。

#1


2  

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!

我可以在版本1,1.5和1.62中确认这一点……在那之后,我感到厌烦了,转而使用Date4J,它看起来工作得很好,满足了我的需要!

http://www.date4j.net/

http://www.date4j.net/

#2


0  

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

仅仅使用java.util.Date()有什么问题吗?

#3


0  

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.

您可以使用来自DDMS透视图的Traceview特性来查看时间的走向。当您这样做时,您将很快看到它的大部分正在初始化时区数据库。

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.

对于我的申请,我知道我只需要几个时区。因此,我在Jodatime源中删除了Olson时区数据库文件,因为我没有使用所有时区。然后我Jodatime重建。

#4


-1  

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

确保您正在使用v1.6.2。在v1.6和v1.6.1中有一个Android问题。