From the JavaDoc of java.sql.Timestamp class(emphasis mine)
Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance.
What does it mean to say implementation inheritance and not type inheritance? Is it a case of HAS-A vs IS-A?
Basically, the documentation states that the fact that java.sql.Timestamp
extends java.util.Date
is an implementation detail, and you should not use Timestamp
instances where you expect to get Date
's functionality. Presumably, if java had the option (like C++ does), Timestamp
would privately inherit from Date
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With