eh3rrera / ocpj8-book

Study guide for the Oracle Certified Professional, Java SE 8 Programmer Exam (1Z0-809)
Other
129 stars 90 forks source link

Typo in Chapter 22 #74

Closed zhengye1 closed 5 years ago

zhengye1 commented 5 years ago

The following example below is wrong

OffsetDateTime odt = OffsetDateTime.of(
    LocalDateTime.now(), ZoneOffset.of(+03:00));
OffsetTime ot = OffsetTime.of(
    LocalTime.now(), ZoneOffset.of(-08:00));

The reason is java cannot compile it, and also ZoneOffset.of() only accept String as parameter.

The fix should be like this

OffsetDateTime odt = OffsetDateTime.of(
    LocalDateTime.now(), ZoneOffset.of("+03:00"));
OffsetTime ot = OffsetTime.of(
    LocalTime.now(), ZoneOffset.of("-08:00"));
eh3rrera commented 5 years ago

You're right. It's fixed. Thanks! 👍