• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 11338
177
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: 37395
531
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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!