Solved

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

Posted on 2002-06-26
2
219 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet concurrency 13 93
maven j2ee examles 2 49
equalIsNot  challenge 43 134
HTTPSessionBindingListernter not configured in deployment descriptor 2 38
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
Knowledge base software has turned out to be a quite reliable method for storing information, promoting collaborative work and for sharing valuable input and solutions.However, some organizations are trying to develop a knowledge base that works wit…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now