I have two Instant objects and would like to get a Duration indicating how much time is between them, however Instant.minus only accepts either a ReadableDuration or a long for the amount of time to change by, and doesn't seem to have any method for subtracting two instants to get the difference between them.
Other answers that I found seem to suggest converting both instants to milliseconds and doing the math myself, but I would prefer something that retains type safety and doesn't require re-implementing end - start logic.
How can I get a Duration from two Instants?
Duration has a constructor which takes two ReadableInstant objects for the start and end of the Duration.
http://joda-time.sourceforge.net/apidocs/org/joda/time/Duration.html#Duration(org.joda.time.ReadableInstant,%20org.joda.time.ReadableInstant)
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