We don't have any multiplication, division or ratio operations at present. While I can understand the use case below, I'm not sure that it is generic enough to form part of Joda-Time itself. Any other views on this?

Stephen


Jim Leask wrote:

I am doing some time calculations on Durations that involve ratios - basically floating point multiplication operations on Durations an Intervals.

For example, I have an event with a start/end time (an Interval) and another event (DateTime) that happened in the middle. I can easily calculate the Duration of the original event, then from that figure out the ratio of where the other event happened in the middle. However, I need to do lots of messing around with millisecond operations, and converting to/from long and float.

Is there an easier way? It would help quite a bit if the Duration class had a 'mult' operator.

I'd like to be able to do something like the following:

Duration durationStartToFinish = new Duration( startDateTime, endDateTime ); Duration durationStartToMiddle = new Duration (startDateTime, middleDateTime);

    float ratio = durationStartToMiddle .divide( durationStartToFinish );

then later....

Interval otherInterval = new Interval( otherStartDateTime, otherFinishDateTime );

    DateTime middleTime = otherInterval.mult( ratio );

or
Duration otherDurationFromStart = otherInterval.toDuration().mult ( ratio );



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to