我正在使用 Joda time android,当我尝试获取两个时间戳之间的差异时,值从 0 增加到 59,并且永远不会超过此值。
我正在使用https://github.com/dlew/joda-time-android
任何指针将不胜感激。
这就是我所拥有的
DateTime currentTime = new DateTime();
Period difference = new Period(calculator.getLastTotalizerChangeTime(meterMeasurement.getFlowMeterId()), currentTime);
Log.d("totaliserSenseCheck", "fcalculator.getLastTotalizerChangeTime() - " + calculator.getLastTotalizerChangeTime(meterMeasurement.getFlowMeterId())
+ " currentTime - " + currentTime
+ " difference - " + difference.getSeconds());
日志 fcalculator.getLastTotalizerChangeTime() 未更改,仅更改当前时间,但差异永远不会超过 59 并重置为 0
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:03:42.730+01:00 difference - 2
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:03:47.335+01:00 difference - 7
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:03:51.113+01:00 difference - 11
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:04:00.793+01:00 difference - 20
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:04:40.369+01:00 difference - 0
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:04:51.574+01:00 difference - 11
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:05:08.914+01:00 difference - 28
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:05:36.840+01:00 difference - 56
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:05:39.070+01:00 difference - 59
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:05:44.526+01:00 difference - 4
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:09:09.579+01:00 difference - 29
D/totaliserSenseCheck: fcalculator.getLastTotalizerChangeTime() - 2019-09-12T16:03:40.002+01:00 currentTime - 2019-09-12T16:09:43.226+01:00 difference - 3