我正在使用 Android 2.2 和 API 级别 8 的模拟器上运行我的应用程序。
我在我的代码中测试了以下两行:
long diffInDays = TimeUnit.MILLISECONDS.toDays(diffInMs); // API Level 9
long diffInDays = TimeUnit.DAYS.convert(diffInMs,TimeUnit.MILLISECONDS); // API Level 1
我正在使用上面的行将时间以毫秒为单位转换为以天为单位的时间,但我得到以下异常。为什么?
09-05 06:34:43.183: W/dalvikvm(12995): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-05 06:34:43.222: E/AndroidRuntime(12995): FATAL EXCEPTION: main
09-05 06:34:43.222: E/AndroidRuntime(12995): java.lang.NoSuchFieldError: java.util.concurrent.TimeUnit.DAYS
09-05 06:34:43.222: E/AndroidRuntime(12995): at org.mabna.order.businessLayer.db.BoSaleDocuments.getEntAcc002Collection(BoSaleDocuments.java:161)
09-05 06:34:43.222: E/AndroidRuntime(12995): at org.mabna.order.ui.ActReportAcc002.onCreate(ActReportAcc002.java:178)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.os.Handler.dispatchMessage(Handler.java:99)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.os.Looper.loop(Looper.java:123)
09-05 06:34:43.222: E/AndroidRuntime(12995): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-05 06:34:43.222: E/AndroidRuntime(12995): at java.lang.reflect.Method.invokeNative(Native Method)
09-05 06:34:43.222: E/AndroidRuntime(12995): at java.lang.reflect.Method.invoke(Method.java:521)
09-05 06:34:43.222: E/AndroidRuntime(12995): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-05 06:34:43.222: E/AndroidRuntime(12995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-05 06:34:43.222: E/AndroidRuntime(12995): at dalvik.system.NativeStart.main(Native Method)