About Question enthuware.ocpjp.v21.2.3791 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
tinohe
Posts: 1
Joined: Fri Jan 10, 2025 2:29 am
Contact:

About Question enthuware.ocpjp.v21.2.3791 :

Post by tinohe »

Hello,
this explanation is wrong imho here:
"date1.compare(date2) will return second date minus first date in seconds i.e. -3600, which, if converted to hours will be -1."

The code doesn't compare the dates, but the ZoneOffsets of these dates. That means -14400 seconds compareTo -18000 seconds = -3600 seconds which equals to -1 hour

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v21.2.3791 :

Post by admin »

But the explanation doesn't say it compares "Dates". It is just showing a trick to find out the answer. It does return a value that can be determined if you do second "date" (date with smallcase d) minus first date in seconds.

What if date1 and date2 have same zoneoffsets?

nkaragulov
Posts: 19
Joined: Mon Sep 16, 2024 1:49 am
Contact:

Re: About Question enthuware.ocpjp.v21.2.3791 :

Post by nkaragulov »

I know -4 is greater than -5. But concerning offset it comes out that -5:00 is greater than -4:00
I don't get it.

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v21.2.3791 :

Post by admin »

Dates are not greater or smaller. They are before or after.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests