You could be right, and perhaps thats working towards the right abstraction. Stephen
Al Major wrote:
weren't they both requirements for expressing one duration as a specific fraction of another duration (and the inverse operation)? operationally it involves dividing one duration length by another. and multiplying a duration by a fraction. but more general duration multiplication / division operations don't seem to be required.Stephen Colebourne wrote:I suppose I should note that this is the second possible example of a requirement for multiply/divide on a duration.Stephen Stephen Colebourne wrote:Carl Henrik Janson wrote:Thanks for providing joda time!Thanks for your interestDateTime end = new DateTime(2006, 3, 16, 9, 21, 0, 0); DateTime start = new DateTime(1960, 3, 1, 9, 45, 0, 0); Period period = new Period(start, end, PeriodType.yyy()); double daysOldWithFraction = period.xxx();I need to produce a number like the format used in excel, inter alias 16815,98 in this example. How do I do that ? Am I on track ? What xxx and yyy produces what I need ?Unfortunately, the Joda-Time model is not setup to suport fractional days, only fractional seconds.There is no simple workaround, as we can't assume that a day is necessarily 24 hours long. Thus, to support your request, the whole model of a period would need to change!The best I can suggest is to use the PeriodType.days() to get the whole number of days between your DateTime objects and then calculate the fraction from the remainder:DateTime start = new DateTime(1960, 3, 1, 9, 45, 0, 0); DateTime end = new DateTime(2006, 3, 16, 9, 21, 0, 0); Period wholeDays = new Period(start, end, PeriodType.days()); DateTime startRemainder = start.plus(wholeDays); DateTime startRemPlusOne = startRemainder.plusDays(1); Duration remainderDur = new Duration(startRemainder, end); Duration wholeDayDur = new Duration(startRemainder, startRemPlusOne); double fraction = remainderDur.getMillis() / wholeDayDur.getMillis(); fraction += wholeDays.getDays(); StephenMany thanks for any reply, hopefully even with a couple of lines of code.Sincerely Carl Henrik Janson-------------------------------------------------------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 [email protected] https://lists.sourceforge.net/lists/listinfo/joda-interest-------------------------------------------------------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 [email protected] https://lists.sourceforge.net/lists/listinfo/joda-interest-------------------------------------------------------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 [email protected] https://lists.sourceforge.net/lists/listinfo/joda-interest
------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/joda-interest
