Possible Duplicate:
How to convert java.util.date to java.sql.date?
I found error on my function, it shows error result after initializing the newInstance() method from DatatypeFactory df , I'm getting another error:
java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date
I just change the package name from
java.util.Date into java.SQL.Date
then casting:
Date dateStarting = (Date) jDateChooserStart.getDate();
Date dateEnding = (Date) jDateChooserEnd.getDate();
How to resolve this issue?
(post before: Convert jcalendar Date into XMLGregorianCalendar Getting Null Value)
It's not possible to cast from
java.util.Date
tojava.sql.Date
. You need to convert from one type to the other instead:From the class cast exception you can see that these are 2 distinct types and can't be cast the from one to the other. To convert from
java.util.Date
tojava.sql.Date
, you can use: