Closed bjoernpollex closed 8 years ago
I would support multipliedBy(long)
, dividedBy(long)
and negated()
as per JSR-310. I tend to avoid double
in Joda-Time.
The floor and ceil operations could be interesting, however the question is always where to draw the line.
Perhaps start with a pull request for multipliedBy, dividedBy and negated?
Thanks for the quick response. Pull request #72 implements the methods you suggested.
I agree that double
does not really make sense in these APIs. The ideal way would be to provide a RationalNumber
class and then an overload Duration.multipliedBy(RationNumber multiplicand)
. Would you support such an approach? (Alternatively an overload Duration.multipliedBy(long numerator, long denominator)
would suffice I think, but internally I'd implement that with a RationalNumber
class as well, to handle reduction among other things).
I would really like to see the floor
and ceil
methods in, because I have repeatedly had a need for them.
I think fractional multiplication is simply multipliedBy followed by dividedBy.
I think I'd accept a dividedBy(long, RoundingMode)
which would cover floor and ceil.
Is this issue still open? I would like to work on this
If you'd like to raise a PR for dividedBy(long, RoundingMode)
I'd consider it.
I would like to have support for the following operations on
Duration
:Duration.scale(double factor)
- stretch the duration by the given factormul(int factor)
anddiv(int factor)
would also make senseDuration.floor(ReadableDuration precision)
- round the duration down to the nearest multiple ofprecision
Duration.ceil(ReadableDuration precision)
- round the duration up to the nearest multiple ofprecision
If no one objects to such operations, I would be happy to fork and implement them.