Solved

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

Posted on 2002-06-26
2
218 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
Comment Utility
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
Comment Utility
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Run the project 5 82
logging jar 1 104
reflections, dynamic class loading 3 63
Using Tomcat as raspberry pi java app server 13 103
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

11 Experts available now in Live!

Get 1:1 Help Now