What's the best way to tell if one joda time DateTime object is within 4 hours of another if I don't know which object is earlier than the other?
The Joda Time Duration object seems to do this job well if I know that object A comes before object B, but since Duration is signed it doesn't seem to do what I want if I don't know the order.
Seems like there would be an easy way to do this, but I haven't found it yet.
Just use the Hours class for this:
Hours h = Hours.hoursBetween(date1, date2);
int hours = h.getHours();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With