I use a period to get the time difference between two DateTimes.
Period p = new Period(startDate, endDate,
PeriodType.standard().withSecondsRemoved().withMillisRemoved());
return PeriodFormat.getDefault().print(p);
It gives me something in the form of "1 hour 30 minutes."
How can I get something like "1:30" or ": 15"?
I suppose I could do something like:
public static int getHoursDifference(DateTime startDate, DateTime endDate) {
Period p = new Period(startDate, endDate);
return p.getHours();
}
And similarly for minutes, and then concatenate ...?
source
share