But even without the conversion toDate(), the time still looks to be off by an 
hour since 12 weeks later, we will be in daylight savings time therefore the 
second value should of been an hour ahead, or am I missing something here?
 
DateTime currentTime = new DateTime(System.currentTimeMillis());      
     2012-02-24T08:42:38.770-08:00
currentTime.plusWeeks(12);
     2012-05-22T08:42:38.770-07:00
Interesting enough everything looks to be the same, here is the information 
printed out:
 
DateTimeZone.getDefault(): America/Los_Angeles
    TimeZone.getDefault(): 
sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
   (DateTime).getZone(): America/Los_Angeles


________________________________
From: Stephen Colebourne <scolebou...@joda.org>
To: Mei Chan <mc...@alumni.washington.edu>; Discussion of the Joda project 
<joda-interest@lists.sourceforge.net> 
Sent: Friday, February 24, 2012 2:50 AM
Subject: Re: [Joda-interest] Daylight Savings Calculation: Off by a hour?

On 24 February 2012 09:08, Mei Chan <mchan...@yahoo.com> wrote:
> My daylight savings calculation using Joda seems to be off by hour and was
> wondering if someone could enlighten me on what the issue may be.  I'm using
> joda version 2.0
>
> Date newDate = new
> DateTime(System.currentTimeMillis()).plusWeeks(12).toDate();
>
> I would of expected something like the following the newly calculated date
> to be (taking in account that we would be in daylight savings)
> Tue May 22 01:49:16 PDT 2012
>
> However, I get the following instead which seems to be off by an hour.
> Tue May 22 00:49:16 PDT 2012

Any time that you convert from a Joda-Time object to a java.util.Date
you add uncertainty. j.u.Date uses the JDK time-zone data, whereas
Joda-Time has its own separate data. Also, j.u.Date always prints the
time in the default time zone.

Try printing out the results of
- DateTimeZone.getDefault()
- TimeZone.getDefault()
- the DateTime you create
- the value of getZone() on the DateTime

Somewhere there will be a difference.

Stephen
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to