java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date
this line
(Date)formatter.parse(str)
returns an java.util.Date
object, but you are casting it to java.sql.Date
. Check your import and adjust it (change from java.sql.Date
to java.util.Date
)