Forums Register Login

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

1
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
 

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)
+Pie Number of slices to send: Send
Thank you!
+Pie Number of slices to send: Send
Added both to the errata list. Thanks for pointing these out!
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1103 times.
Similar Threads
OCA Java SE 7 Associate Study Guide
OCA Java 7 - preparing
Passed: OCA Java SE 7.
Optimization Code (OCA JAVA SE 7 - Programmer I - Study Guide )
Passed OCA-1Z0-803 today
OCA Java SE 8 Programmer I Study Guide: Exam 1Z0-808 by Jeanne Boyarsky & Scott Selikoff
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:48:23.