How do I compare a joda datetime object with an acceptable offset (tolerance)?

I wonder if there is any standard API in jodatime to compare 2 datetime objects with specified tolerance?

Ideally, it would be like this:

boolean areNearlyEqual = SomeJodaAPIClass.equal(dt1,dt2,maxTolerance);

thank you!

Solution

Use this:

new Duration(dt1,dt2).isShorterThan(Duration.millis(maxTolerance))
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>