Safe to convert Java.sql.date to Java.util.date by up casting?

date, java, jdbc

Solution

Yes, you can just upcast it.

The `java.sql.Date` is in fact nothing less or more than a representation of the SQL Date type, which has only year, month and day filled.

Problem

Java.sql.date extends java.util.date, so is it save to convert between the two by casting a java.sql.date as a java.util.date? Or is there some other way to convert them?

Original source