• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Bear Bibeault
  • paul wheaton
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Mikalai Zaikin
  • Piet Souris
Bartenders:

Working with Dates and Times (Java OCA 8 Programmer I Study Guide)

 
Greenhorn
Posts: 18
3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have found 2 minor "errors" in the "OCA Java SE 8 Programmer I" book.

On page 141, a parameter name is missing in the last method signature:
public static LocalDateTime of(LocalDate date, LocalTime <missing>)

On page 147, after the following code: Period wrong = Period.ofYears(1).ofWeeks(1);
the explanation gives the following lines of code:
Period wrong = Period.ofYears(1);
wrong = Period.ofWeeks(7); --> should be replaced with : wrong = Period.ofWeeks(1);

Is that correct?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cedric Georges wrote:On page 141, a parameter name is missing in the last method signature:
public static LocalDateTime of(LocalDate date, LocalTime <missing>)


According to the javadoc of LocalDateTime, the method signature should be (as you would probably expect):

Cedric Georges wrote:On page 147, after the following code: Period wrong = Period.ofYears(1).ofWeeks(1);
the explanation gives the following lines of code:
Period wrong = Period.ofYears(1);
wrong = Period.ofWeeks(7); --> should be replaced with : wrong = Period.ofWeeks(1);


Yes, it's incorrect! Probably because in the previous code snippet 7 days is used to simulate 1 week. The correct code should be:And maybe it would even better to have the following code (as it's the perfect equivalent of Period everyYearAndAWeek = Period.of(1, 0, 7);:

Hope it helps!
Kind regards,
Roel

(PS. I notified the authors of these errata items)
 
Cedric Georges
Greenhorn
Posts: 18
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!
 
author & internet detective
Posts: 41763
885
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
Added both to the errata list. Thanks for pointing these out!
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic