File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Convert java.util.Date to java.sql.Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Convert java.util.Date to java.sql.Date" Watch "Convert java.util.Date to java.sql.Date" New topic

Convert java.util.Date to java.sql.Date

Kop Ite

Joined: Aug 06, 2001
Posts: 9

I am trying to convert a java.util.Date into java.sql.Date as below:
java.util.Date aDate
(java.sql.Date) aDate
< where aDate = Mon Nov 11 00:00:00 GMT 2002 >
I am getting exception:
java.lang.ClassCastException: java.util.Date
How do I sort this out so it will work remembering that aDate value is set in stone, so nothing can be done with that, must be converted into java.sql.Date.
Help !!
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Kop Ite

Joined: Aug 06, 2001
Posts: 9
thanks works a treat
I agree. Here's the link:
subject: Convert java.util.Date to java.sql.Date
It's not a secret anymore!