This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Errata on the Sybex bonus exam 3  RSS feed

 
Omar B. Cisse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Why would this code:
LocalDate date=LocalDate.of(2015, Month.NOVEMBER, 6);
LocalTime time=LocalTime.of(1, 30);
ZoneId zone=ZoneId.of("US/Eastern");
ZonedDateTime dateTime1=ZonedDateTime.of(date, time,zone);
System.out.println("dateTime1: "+dateTime1);
output
this:  dateTime1: 2015-11-06T01:30-04:00[US/Eastern] instead of dateTime1: 2015-11-06T01:30-05:00[US/Eastern]?
My jdk is 1.8.0_66.
In the book, page 252, it is written that the piece of code above should display  2015-11-06T01:30-04:00[US/Eastern] . This is not the case in my environment.

Executing the code does not provide answer C as the good answer but answer D because dateTime1 is  2015-11-06T01:30-05:00[US/Eastern].


Errata_question15.png
[Thumbnail for Errata_question15.png]
Errata_question15_2.png
[Thumbnail for Errata_question15_2.png]
 
Omar B. Cisse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I wanted to add that I am running the code from France :


Even setting the default timeZone to be US/Eastern does not help:
The result is still:

Current Default time zone: sun.util.calendar.ZoneInfo[id="Europe/Paris",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=184,lastRule=java.util.SimpleTimeZone[id=Europe/Paris,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
US/Eastern time zone: sun.util.calendar.ZoneInfo[id="US/Eastern",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=US/Eastern,offset=-18000000,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]]
dateTime1: 2017-11-06T01:30-05:00[US/Eastern]
dateTime2: 2017-11-06T02:30-05:00[US/Eastern]
1, 1, 2
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Omar,
Sorry for the delay. I'm still trying to reverse engineer what we were thinking with that one.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Omar,
Found it! In the text of the question online and in your screenshot, it says the year is 2016. In your code snippet in this thread, you have 2015. In 2015, that wasn't the day clocks changed so the behavior is different.

I ran your example changing 2015 to 2016 and it matches Option C.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!