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
About Question enthuware.ocpjp.v21.2.3791 :
Moderator: admin
-
- Posts: 1
- Joined: Fri Jan 10, 2025 2:29 am
- Contact:
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.3791 :
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?
What if date1 and date2 have same zoneoffsets?
-
- Posts: 19
- Joined: Mon Sep 16, 2024 1:49 am
- Contact:
Re: About Question enthuware.ocpjp.v21.2.3791 :
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.
I don't get it.
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.3791 :
Dates are not greater or smaller. They are before or after.
Who is online
Users browsing this forum: No registered users and 10 guests