Just idly wondering really, the DateTime class in the awesome JodaTime library has a
minus(long millis)
method, which returns a new DateTime object minus the specified number of milliseconds, so why would I ever need the
minusMillis(int millis)
method, which does the same but with an Integer number of milliseconds? Integer.MAX_VALUE in milliseconds is only 24 days, which isn't that helpful, and presumably it just converts the int to a long and pumps it into the other method anyway?
The JodaTime library is so well written that I figure there's probably a reason that I'm missing.
http://joda-time.sourceforge.net/api-release/org/joda/time/DateTime.html#minusMillis(int)
EDIT: To clarify, I'm wondering why I should use the minusMillis(int) method - I understand what the more powerful minus(long) method is for.
I suspect its because in version 1.0 there way only the minus(long duration) method but in version 1.1 there was minusXxxx(int units) added resulting in minusMillis(int) being add for consistency and minus(long) was not removed for back-ward compatibility.
BTW: there is a plus(long duration) and a plusMillis(int millis) for, I imagine, the same reasons.
The method minusMillis(int millis), can subtract maximum Integer.Max milliseconds which when converted to days is (2^31 -1) is roughly 24.8 days
so if you want to subtract two date objects such that date1 -(no. of days) where no.of days is > 29, then you cannot do it using minusMillis(int millis), therefore the method
DateTime minus(long duration)
is provided.
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