这是我第一次使用jodatime而且我遇到了stackoverflow错误,我不知道如何修复。我正在创建一个Android应用程序,需要能够显示创建sqlite记录和今天之间的日子。据我所知,一切都正常,除了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:
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二进制文件。 我一直在使用eclipse,我创建了一个新项目,并导入了jodatime源代码。当我尝试编译时,我在控制台中得到它:
Usage: java org.joda.time.tz.ZoneInfoCompiler <options> <source files>
可能的选项包括: -src指定读取源文件的位置 -dst指定生成文件的写入位置
不确定从哪里开始。任何帮助将不胜感激。谢谢你的时间。
来自溢出的StackTrace:
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 :(得分:2)
有问题的递归显然在DateTimeZone.getDefault
和DateTimeZone.forID
之间。但是,堆栈行号似乎与Joda源代码({3}}不一致。在该代码中,DateTimeZone.getDefault()
方法不会查看系统属性......这些内容发生在静态初始化程序中。
似乎Android代码库使用了JodaTime的调整版本。
无论如何,看起来调用JodaTime.setDefault(...)
可能是一种解决方法。另外,请检查是否已设置“user.timezone”系统属性。
(我不认为重新编译/使用标准JodaTime是正确的策略.Android调整......无论它们是什么......都可能是有原因的。)
修改强>
重新审视这一点,发现在某些平台(Android,Google-Apps)上这是JodaTime 1.6.1中的一个错误。问题跟踪器在JodaTime 1.6.2中将其显示为已修复。
答案 1 :(得分:0)
为什么你不能使用类似的东西:
SELECT julianday('now') - julianday('1776-07-04');
在您的查询中?
答案 2 :(得分:0)
我只是有同样的问题,我认为这是joda-time 1.6.1中的一个错误,因为所有运行良好的版本1.6版本。我在joda-time bug跟踪器上发布了一个错误报告,我使用1.6版本。
圣保罗