• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Errata on the Sybex bonus exam 3

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Omar B. Cisse
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Jeanne for your answer. I have learnt something new: daylight saving time changes each year.
In 2017 Spring forward on March 12, fall back on November 5th;
in 2016 spring forward on March 13th, fall back on November 6th;
in 2015 spring forward on March 8th, fall back on November 1st;
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Omar B. Cisse wrote:Thank you Jeanne for your answer. I have learnt something new: daylight saving time changes each year.
In 2017 Spring forward on March 12, fall back on November 5th;
in 2016 spring forward on March 13th, fall back on November 6th;
in 2015 spring forward on March 8th, fall back on November 1st;


Right. And the exam question tells you when it is if in the vicinity of the question. They don't expect you to memorize the dates. (The date changes because it is always a Saturday night/Sunday morning changeover)
 
reply
    Bookmark Topic Watch Topic
  • New Topic