I wonder is there any standard API in JodaTime
to compare 2 DateTime
objects with specified tolerance?
I am looking for a one-liner preferably by using Joda
standard API. Not for time-aritmethic expressions like in this post.
Ideally, it would be something like:
boolean areNearlyEqual = SomeJodaAPIClass.equal(dt1, dt2, maxTolerance);
Thanks!
Use this:
This post is old, but I find the line in the accepted solution a bit long and I found nothing better in what exists. So I did a small class that wraps it for Date and DateTime :
so this line :
becomes :
I found that really useful in unit test cases where I needed to validate a creation date.