Hi, To convert a period to a duration you need a base point on the timeline. This is because for periods including days, weeks, months and years, the duration of a period in milliseconds varies by the base point (eg. one day could be 23, 24 or 25 hours long according to whether the base date is at a DST change.
With a base date you can use http://joda-time.sourceforge.net/api-release/org/joda/time/base/BasePeriod.html#toDurationFrom(org.joda.time.ReadableInstant) When you don't care about the base date (as in this case) you can just use new Instant(0L) or null. Stephen On 23/09/06, Jason Bennett <[EMAIL PROTECTED]> wrote: > > I'm just starting to use Joda, and I seem to have hit somewhat of a wall. > > I'm adding up a bunch of intervals into a duration like: > > d = d.plus( iv.toDuration() ); (where d is a duration created with a ZERO > length) > > Once I have the total duration, I want to know if it is longer than a > specified > number of hours. Unfortunately, I can't find a way in Joda to create a > duration > given anything but millis, and no way to convert hours to millis. > > I can create a period, but cannot convert it into a duration without an > interval. I could create a period and pull the hours value out, but I'm not > sure > that's correct. > > Appreciate any suggestions. > > jason > > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Joda-interest mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/joda-interest > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Joda-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/joda-interest
