2010-08-14 84 views
0

这是我第一次使用jodatime和我有一个stackoverflow错误,我不知道如何解决。我正在创建一个android应用程序,它需要能够显示sqlite记录创建和今天之间的时间。至于我可以告诉一切正常工作,除了乔达泰。重新编译jodatime?

 
08-13 22:12:11.823: ERROR/AndroidRuntime(6537): Uncaught handler: thread main exiting due to uncaught exception 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537): java.lang.StackOverflowError 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537):  at java.util.Hashtable.get(Hashtable.java:274) 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537):  at java.util.Properties.getProperty(Properties.java:177) 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537):  at java.lang.System.getProperty(System.java:440) 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537):  at java.lang.System.getProperty(System.java:412) 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537):  at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132) 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537):  at org.joda.time.DateTimeZone.forID(DateTimeZone.java:190) 
08-13 22:12:11.893: ERROR/AndroidRuntime(6537):  at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132) 

环视了一下后,我想我只需要重新编译的二进制jodatime我自己:建设项目

 
[2010-08-10 02:08:50 - Grow Journal Beta] processing org/joda/time/DateTimeUtils.class... 
[2010-08-10 02:08:50 - Grow Journal Beta] processing org/joda/time/DateTimeZone$1.class... 
[2010-08-10 02:08:50 - Grow Journal Beta] warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) 
[2010-08-10 02:08:50 - Grow Journal Beta] processing org/joda/time/DateTimeZone$Stub.class... 

时,这是logcat的我得到这个错误。 我一直在使用eclipse,我创建了一个新项目,并导入了jodatime源代码。当我尝试编译我得到这个在控制台:

Usage: java org.joda.time.tz.ZoneInfoCompiler <options> <source files> 

在可能的选项包括: -src指定要读取源文件 -dst指定在哪里写入生成的文件

不是真的知道在哪里从这里出发。任何帮助将不胜感激。谢谢你的时间。从溢流

堆栈跟踪:

Thread [ main] (Suspended (exception StackOverflowError)) 
    DateTimeZone.getDefault() line: 147 
    ISOChronology.getInstance() line: 86  
    DateTimeUtils.getChronology(Chronology) line: 231 
    DateConverter(AbstractConverter).getChronology(Object, Chronology) line: 82 
    DateTime(BaseDateTime).(Object, Chronology) line: 170 
    DateTime.(Object) line: 168 
    PlantsCursorAdapter.newView(Context, Cursor, ViewGroup) line: 71  
    PlantsCursorAdapter(CursorAdapter).getView(int, View, ViewGroup) line: 182 
    ListView(AbsListView).obtainView(int) line: 1274  
    ListView.measureHeightOfChildren(int, int, int, int, int) line: 1147  
    ListView.onMeasure(int, int) line: 1060 
    ListView(View).measure(int, int) line: 7966 
    TableLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 3077 
    TableLayout(LinearLayout).measureChildBeforeLayout(View, int, int, int, int, int) line: 888 
    TableLayout.measureChildBeforeLayout(View, int, int, int, int, int) line: 453 
    TableLayout(LinearLayout).measureVertical(int, int) line: 350 
    TableLayout.measureVertical(int, int) line: 465 
    TableLayout.onMeasure(int, int) line: 428 
    TableLayout(View).measure(int, int) line: 7966 
    FrameLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 3077 
    FrameLayout.onMeasure(int, int) line: 245 
    FrameLayout(View).measure(int, int) line: 7966 
    LinearLayout.measureVertical(int, int) line: 464  
    LinearLayout.onMeasure(int, int) line: 278 
    LinearLayout(View).measure(int, int) line: 7966 
    PhoneWindow$DecorView(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 3077 
    PhoneWindow$DecorView(FrameLayout).onMeasure(int, int) line: 245  
    PhoneWindow$DecorView(View).measure(int, int) line: 7966  
    ViewRoot.performTraversals() line: 767 
    ViewRoot.handleMessage(Message) line: 1650 
    ViewRoot(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 123 
    ActivityThread.main(String[]) line: 4595  
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] 
    Method.invoke(Object, Object...) line: 521 
    ZygoteInit$MethodAndArgsCaller.run() line: 860 
    ZygoteInit.main(String[]) line: 618 
    NativeStart.main(String[]) line: not available [native method] 

DateTimeZone.class源是Here

+0

您确定stacktrace不再更长? StackOverflow通常是一个递归错误 – TheLQ 2010-08-14 03:49:28

+0

我已添加跟踪,我有 – Brian 2010-08-14 04:34:44

+0

@ Lord。Quackstar - 递归在'DateTimeZone.getDefault'和'DateTimeZone.forID'之间。 – 2010-08-14 04:46:25

回答

2

有问题的递归显然之间DateTimeZone.getDefaultDateTimeZone.forID。然而,堆栈行号似乎并不符合Joda源代码,我看到here。在该代码中,DateTimeZone.getDefault()方法不会查看系统属性......这些东西发生在静态初始化器中。

似乎Android代码库使用JodaTime的微调版本。

无论如何,它看起来像打电话JodaTime.setDefault(...)可能是一种解决方法。另外,请检查“user.timezone”系统属性是否已设置。

(我不认为重新编译/使用标准JodaTime是正确的策略。而Android的调整......不管他们是......可能是有原因的。)

编辑

回想一下,它发现这是在某些平台(Android,Google-Apps)上的JodaTime 1.6.1中的一个错误。问题跟踪器显示它在JodaTime 1.6.2中已修复。

+0

我不相信jodatime包含在Android代码库中,因为我不得不导入库。我添加了一个链接到更新的DateTimeZone类,我正在使用和发现使用谷歌代码搜索。 – Brian 2010-08-14 13:07:32

0

为什么你不能使用类似:

SELECT julianday('now') - julianday('1776-07-04'); 

在您的查询?

+0

我从来没有在java中使用过sqlite的原始查询,可否提供一个简单的例子来寻找现在和TABLE_A中的DATE字段之间的日期,该日期字段也匹配我在HOME_ID字段中指定的变量。我被指出为了它的舒适或使用,但它似乎与我完全相反。 – Brian 2010-08-14 21:47:38

0

我只是有同样的问题,我认为这是一个bug在joda时间1.6.1,因为所有运行良好whis 1.6版本。我发布了一个关于joda-time bug跟踪器的bug报告,我使用1.6版本。

Paulo