Reputation: 5177
I have two DateTime instances and i would like to find out the exact difference between them. I am using the following
DateTime dt = DateUtils.convertFromString(user.getUpdated());
DateTime now = DateTime.now();
Hours hours = Hours.hoursBetween(now, dt);
This off course only gives me the Hours between the two dates. I need the complete values like X Day y hours and z minutes. How can i do this ?
Upvotes: 1
Views: 356
Reputation: 1499770
Use Period
:
Period period = new Period(now, dt);
You can provide a PeriodType
which specifies exactly which units you want.
(If dt
was in the past, you probably actually want new Period(dt, now)
instead, to give a positive period.)
Upvotes: 1