jdbc - Get the current date in java.sql.Date format -
i need add current date prepared statement of jdbc call. need add date in format yyyy/mm/dd
.
i've try with
dateformat dateformat = new simpledateformat("yyyy/mm/dd"); date date = new date(); pstm.setdate(6, (java.sql.date) date);
but have error:
threw exception java.lang.classcastexception: java.util.date cannot cast java.sql.date
is there way obtain java.sql.date
object same format?
a java.util.date
not java.sql.date
. it's other way around. java.sql.date
java.util.date
.
you'll need convert java.sql.date
using constructor takes long
java.util.date
can supply.
java.sql.date sqldate = new java.sql.date(utildate.gettime());
Comments
Post a Comment