Hello JodaTime Users,
I just noticed a strange behavior of JodaTime and was wondering if this
is a bug in the library.  I've tested with jodatime 1.3 and 1.1 on JDK
1.5.03 on Windows (same problem on Solaris though) and my local timezone
is EST.  I understand that in the US the daylight time rules change as
of 2007 when daylight time begins on March 11th and ends on November
4th.

I am basically parsing a string with only a date element and noticed
while running with jodatime 1.3 the time zone information is off and it
is still EDT (-04:00) instead of EST (-05:00).  When running with
jodatime 1.1 everything is fine.  Does this perhaps have anything to do
with the time zone updates regarding the US daylight savings time rules
changes that went into jodatime > 1.1 ?

Below is some code and outputs using the different libraries:

    public void testJodaDateParsing() throws Exception {
        DateTimeFormatter JODA_JDK_LIKE_FORMATTER =
DateTimeFormat.forPattern("EE MMM d HH:mm:ss zz yyyy");
        DateTimeFormatter JODA_DATE_FORMATTER =
DateTimeFormat.forPattern("M/d/yyyy");
        SimpleDateFormat  JDK_DATE_FORMATTER  = new
SimpleDateFormat("M/d/yyyy");
        
        String dateStr = "3/20/2011";
        Date jdkDate      = JDK_DATE_FORMATTER.parse(dateStr);
        DateTime jodaDate = JODA_DATE_FORMATTER.parseDateTime(dateStr);
        
        System.out.println("Millis jodaDate: " + jodaDate.getMillis() +
"\t : " + JODA_JDK_LIKE_FORMATTER.print(jodaDate));
        System.out.println("Millis jdkDate : " + jdkDate.getTime()    +
"\t : " + jdkDate);
        System.out.println("JODA_DATE_FORMATTER.getZone(): " +
JODA_DATE_FORMATTER.getZone());
        System.out.println("DateTimeZone.getDefault()    : " +
DateTimeZone.getDefault());
        System.out.println("TimeZone.getDefault()        : " +
TimeZone.getDefault());
    } //END: testJodaDateParsing()

For jodatime 1.3:
------------------------------------------------------------------------
-----------------
Millis jodaDate: 1300593600000   : Sun Mar 20 00:00:00 EDT 2011
Millis jdkDate : 1300597200000   : Sun Mar 20 00:00:00 EST 2011
JODA_DATE_FORMATTER.getZone(): null
DateTimeZone.getDefault()    : America/New_York
TimeZone.getDefault()        :
sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSav
ings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleT
imeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDayli
ght=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayOfWeek=
1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDa
yOfWeek=1,endTime=7200000,endTimeMode=0]]
------------------------------------------------------------------------
-----------------

For jodatime 1.1:
------------------------------------------------------------------------
-----------------
Millis jodaDate: 1300597200000   : Sun Mar 20 00:00:00 EST 2011
Millis jdkDate : 1300597200000   : Sun Mar 20 00:00:00 EST 2011
JODA_DATE_FORMATTER.getZone(): null
DateTimeZone.getDefault()    : America/New_York
TimeZone.getDefault()        :
sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSav
ings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleT
imeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDayli
ght=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayOfWeek=
1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDa
yOfWeek=1,endTime=7200000,endTimeMode=0]]
------------------------------------------------------------------------
-----------------

Regards,
Sebastian

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - -

This message is intended only for the personal and confidential use of the 
designated recipient(s) named above.  If you are not the intended recipient of 
this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited.  This 
communication is for information purposes only and should not be regarded as an 
offer to sell or as a solicitation of an offer to buy any financial product, an 
official confirmation of any transaction, or as an official statement of Lehman 
Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  
Therefore, we do not represent that this information is complete or accurate 
and it should not be relied upon as such.  All information is subject to change 
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this 
communication (including any attachments) is not intended or written to be used 
and cannot be used for the purpose of (i) avoiding U.S. tax related penalties 
or (ii) promoting, marketing or recommending to another party any transaction 
or matter addressed herein.



-------------------------------------------------------------------------
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

Reply via email to