Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calendar.before(Object when), why Object?

Tags:

java

calendar

From the javadoc of Calendar.before(Object when):

Returns whether this Calendar represents a time before the time represented by the specified Object. This method is equivalent to:

compareTo(when) < 0

if and only if when is a Calendar instance. Otherwise, the method returns false.

Why does it accepts an Object if when someone passes something that's not a Calendar instance it returns false? Why not just accepting a Calendar instance? This kept me watching for uncorrect results in a functionality for quite some time.

like image 922
Alberto Zaccagni Avatar asked Sep 21 '10 09:09

Alberto Zaccagni


1 Answers

I think there is no particular reason for that. java.util.Calendar has some design issues we have have to live with, unfortunately.

like image 118
DerMike Avatar answered Oct 15 '22 10:10

DerMike