JSP: converting a string to be stored in SQL date format YYYY-MM-DD

I'm reading a date in from a POST in the format MM/DD/YYYY and need to convert it to go into datetime format for sql:

yfudAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
objectsConnect With a Mentor Commented:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
java.sql.Date d = new java.sql.Date(sdf.parse(string).getTime());

// Construct your Prepared statement

PreparedStatement s = ....

s.setDate(column, d);


0
 
objectsCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.