convert String to sql.Date - seems not so easy to me
Seems easy but it appears not to be a "normal" cast.
I need a way to convert input strings into sql.date objects to store them in my DB trough PreapredStatement*.setDate().
I tried all the ways founded in forum but noone seems to works.
Anybody knows a working code sequence?
Thanks!
# 1
The string needs to be in the JDBC format (yyyy-mm-dd) for the following to work:java.sql.Data theDate = java.sql.Date.valueOf(theString);
or you could do something like:java.util.Date utilDate = new SimpleDateFormat("dd.MM.yyyy").parse(theString); // or use whatever format your string is in
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
dwga at 2007-7-12 19:53:25 >
