By your current posted code:
st.SetDate(3,"Jan. 14,2014");
This does not even compile. You could try getting a new Date
object from a String
(since this is what you're trying to accomplish), so use a SimpleDateFormat
for this:
SimpleDateFormat sdf = new SimpleDateFormat("MMM. dd,yyyy");
Date date = sdf.parse("Jan. 14,2014");
st.setDate(3, new java.sql.Date(date.getTime()));
//rest of your code...
Similar to this, you can parse time or date and time into a java.util.Date
using SimpleDateFormat
and then convert it to the respective class java.sql.Time
and java.sql.Timestamp
using date.getTime()
.
Also note that you can p̶a̶s̶s̶ retrieve a java.util.Date
object reference to PreparedStatement#getDate
(and getTime
and getTimestamp
) since java.sql.Date
, java.sql.Time
and java.sql.Timestamp
extend from java.util.Date
. For more info, please refer here: Date vs TimeStamp vs calendar?