Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object methods vs static methods 2 97
constuctor calling other constructor 2 76
'exit' is not valid keyword in java 14 152
Handle form fields in spring mvc controller 1 64
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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