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();
I suspect you're asking the wrong question of Joda-Time. Try looking at the Period class:
ie
Period
breaks the time down into days and hours for you, correctly handling daylight savings time (which your original method and manual % calculations do not).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):