So...Period and Duration represent basically the same thing right, except
Duration can only retrieve the milliseconds while Period gives access to all
individual fields with the potential for loss of precision? Is there any
reason the two classes couldn't be combined?
For example, a lot of timeout APIs normally have something looking like
this:
public void setTimeout(long timeoutInMilliseconds) {}
A normal call for 2 seconds would look something like this (with added doc
to help readers know the unit):
setTimeout(2000); // in milliseconds
What type would you recommend to replace the long here? Duration or Period?
I like Period because it allows easy construction of time durations using
non-millisecond units.
If I made it take Duration, calls would look something like:
setTimeout(Period.seconds(2).toStandardDuration().getMillis());
Not that pretty. Period would be much more concise.:
setTimeout(Period.seconds(2));
Again I think these two classes could be combined and make the API more
uniform. What do you think?
On Mon, Aug 25, 2008 at 5:51 AM, Stephen Colebourne <[EMAIL PROTECTED]>wrote:
> There is no Milliseconds class because Duration models time in
> milliseconds. The latest SVN has more methods to convert between the
> different types if I remember correctly.
>
> Stephen
>
>
> Matt Hughes wrote:
> > One of my programming bugbears is when coders use a primitive such as
> > 'int' to represent some unit of time so I was pleased when I found the
> > Period class in joda-time but dismayed to find no milliseconds support.
> >
> > Why is there no Milliseconds class to parallel all the others (Seconds,
> > Hours, Days, etc). My code base interacts with many APIs that expect
> > their timeouts to be in milliseconds. What I would like to do is pass
> > around a Period instance for as long as I can until I bump up to one of
> > those APIs and convert that value into milliseconds. Is there any
> > reason that class couldn't be added and the added
> > toStandardMilliseconds? I'd be happy to submit a patch.
> >
> >
> > ------------------------------------------------------------------------
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> > Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> > Grand prize is a trip for two to an Open Source event anywhere in the
> world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Joda-interest mailing list
> > Joda-interest@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/joda-interest
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> Joda-interest@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest