It's not a secret anymore!
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
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
subject: Convert java.util.Date to java.sql.Date
jQuery in Action, 3rd edition