Solved

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

Posted on 2002-06-26
2
222 Views
Last Modified: 2010-05-18
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:

0
Comment
Question by:yfud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 7112470
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
 
LVL 92

Expert Comment

by:objects
ID: 7120728
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The world seems to conceive of a curious bubble separating IT from “the business.”  More so than just about any other pursuit in the commercial world, people think of IT as some kind of an island.
Read the original post on Monitis Blog. Believe it or not, the most important thing about the website of your business is not what’s on it but how fast it loads. Yes, that’s right!    As you can see on this infographic (an oldie but goodie!), …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question