error casting Java.Util.Date into Java.Sql.Date
casting, datetime, java, time
Solution
It's not possible to cast from `java.util.Date` to `java.sql.Date`. You need to convert from one type to the other instead:
java.util.Date utilStartDate = jDateChooserStart.getDate();
java.sql.Date sqlStartDate = new java.sql.Date(utilStartDate.getTime());
Problem
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)