Try using the Period constructor that accepts a PeriodType.

 

    /**

     * Creates a period from the given interval endpoints.

     *

     * @param startInstant  interval start, in milliseconds

     * @param endInstant  interval end, in milliseconds

     * @param type  which set of fields this period supports, null means
standard

     */

    public Period(long startInstant, long endInstant, PeriodType type)

 

 

Bryan

 

From: Elam Daly [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 30, 2008 9:51 AM
To: Discussion of the Joda project
Subject: Re: [Joda-interest] Misunderstanding Period Class.

 

Well, using this particular example, all the toStandardXXX methods are
throwing exceptions because of the presence of years in the Period, as the
Javadocs state.  So is there a way around this, ie to convert a period of
months/years into minutes/hours etc?

Thanks,
- Elam

On Tue, Sep 30, 2008 at 10:36 AM, Matt Hughes <[EMAIL PROTECTED]> wrote:

Because the getXXX methods just return that FIELD of time.  If you want the
computed time, you need the toStandardXXX method.

On Tue, Sep 30, 2008 at 9:41 AM, Elam Daly <[EMAIL PROTECTED]> wrote:

Hi all,

I'm trying this simple example to understand the Period class.  

Why does the getDays() method return 0, instead of 472?

Thanks,
- Elam

DateTime start = new DateTime(2004, 12, 25, 0, 0, 0, 0);
DateTime end = new DateTime(2006, 1, 1, 0, 0, 0, 0);

// period of 1 year and 7 days
Period period = new Period(start, end);
System.out.println(period.getDays()); // Returns 0

 

-------------------------------------------------------------------------
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
<http://moblin-contest.org/redirect.php?banner_id=100&url=/> &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
<http://moblin-contest.org/redirect.php?banner_id=100&url=/> &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

Reply via email to