与乔达时间的Android时间差 [英] Android time difference with joda time
问题描述
我有这个简单的code,使用乔达时间。
工作正常,但我有一个问题。
例如,它返回814分钟,有什么用code,它的确定。
但我想要的结果小于60分钟,不能814分钟。
所以,我怎么可以转换814分钟得到我想要的结果?
同样发生在营业时间。
感谢你。
在code:
INT天= Days.daysBetween(新的日期时间(今天),新的日期时间(StartTime1))getDays()。
INT小时= Hours.hoursBetween(新的日期时间(今天),新的日期时间(StartTime1))getHours()。
INT分钟= Minutes.minutesBetween(新的日期时间(今天),新的日期时间(StartTime1))getMinutes()。
您在几分钟的总数,所以你需要获得60分钟划分分钟的剩余部分(假设你正在跟踪的时间在你的时间变量):
分钟=分钟%60;
I have this simple code, using Joda-time.
Works fine, but I have a problem.
For example, it returns 814 minutes, what by the code, it's ok.
But I want the result to be less than 60 minutes, not the 814 minutes.
So, how can I convert that 814 minutes to get the result that I want ?
The same happens in Hours.
Thank you.
The code:
int days = Days.daysBetween(new DateTime(today), new DateTime(StartTime1)).getDays();
int hours =Hours.hoursBetween(new DateTime(today), new DateTime(StartTime1)).getHours();
int minutes = Minutes.minutesBetween(new DateTime(today),new DateTime(StartTime1)).getMinutes();
You have the total number of minutes, so you need to get the remainder of the minutes divided by 60 minutes (assuming you are keeping track of the hours in your hours variable):
minutes = minutes % 60;
这篇关于与乔达时间的Android时间差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!