Indeed, the code for the period class uses a different strategy for calculating time, thus
Period difference = new Period(ymd, ymd2);
will actually work. Oh the confusion...

Perhaps you can appreciate why LocalDate is needed to sort out the mess ;-)

The way to know for sure is to look at the source code of any Joda-Time method.

Stephen


On 30/05/06, Richardson, James <[EMAIL PROTECTED]> wrote:
Hmm... I'm not sure I buy it...
 
Try this:
 
    public static void main(String[] args) {
 
        YearMonthDay ymd = new YearMonthDay(2006,5,22);
        YearMonthDay ymd2 = new YearMonthDay(2006,5,30);
 
        Period difference = new Period(ymd, ymd2);
 
        System.out.println(difference);
 
        DateMidnight dt = ymd.toDateMidnight();
 
        System.out.println(dt.plus(difference));
        System.out.println(ymd.plus(difference));
    }
 
 
If what you are saying wasn't a bug, then the period "difference" would be "8D", not "1W1D"...
 
Best Regards,
 
James
 
PS: not to detract from joda, which is extremely useful!

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Stephen Colebourne
Sent: 30 May 2006 17:26
To: [email protected]
Subject: Re: [Joda-interest] Weeks not added to YearMonthDay?

This is not a bug, however it is confusing.

YearMonthDay does exactly what it says - it holds a Year, Month and Day field internally, and only allows operations on those three fields. As a result, adding a week has no effect, as weeks are an ignored field.

For the next release, v1.3, there will be a new class, LocalDate, which will behave as you expect.

Stephen

On 30/05/06, Richardson, James <[EMAIL PROTECTED]> wrote:

This doesn't output the result I expected:

    public static void main(String[] args) {

        YearMonthDay ymd = new YearMonthDay(2006,5,23);
        DateMidnight dt = ymd.toDateMidnight();
        Period p = new Period(0, 0, 2, 0, 0, 0, 0, 0);
        System.out.println(dt.plus(p));
        System.out.println(ymd.plus(p));
    }

Change the period to use any other field and it will work, just not weeks.

This seems to be a bug?

Cheers

James





--------------------------------------------------------------------------------
The information contained herein is confidential and is intended solely for the
addressee. Access by any other party is unauthorised without the express
written permission of the sender. If you are not the intended recipient, please
contact the sender either via the company switchboard on +44 (0)20 7623 8000, or
via e-mail return. If you have received this e-mail in error or wish to read our
e-mail disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.
--------------------------------------------------------------------------------



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest



--------------------------------------------------------------------------------
The information contained herein is confidential and is intended solely for the
addressee. Access by any other party is unauthorised without the express
written permission of the sender. If you are not the intended recipient, please
contact the sender either via the company switchboard on +44 (0)20 7623 8000, or
via e-mail return. If you have received this e-mail in error or wish to read our
e-mail disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.
--------------------------------------------------------------------------------

------


Reply via email to