Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Cedric Georges
Greenhorn
Posts: 18
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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?
 
Roel De Nijs
Sheriff
Posts: 10763
148
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Added both to the errata list. Thanks for pointing these out!
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!