The title says it all. 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?
+1
A:
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.
BalusC
2010-01-29 20:44:50
What was that downvote about? :D
BalusC
2010-01-30 04:48:23
+3
A:
You don't necessarily need to cast, you can just treat a SQL Date as if it was a util Date:
java.sql.Date sqlDate = new java.sql.Date(whenever);
java.util.Date utilDate = sqlDate;
Compiles and runs just fine.
mattjames
2010-01-29 20:58:45