Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
java beans and EJBs 5 196
J2SE 5.0 metadata 1 61
constructor overloading 2 86
JavaScript parse form with colon separated values 2 78
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
This article describes how to reset your Windows 10 password when you've forgotten it.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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