1. How to validate Date so that it should satisfy dd-mm-yyyy format?
This is working fine with same code mentioned by Annie. It is validating the required format.
2. How to insert validated Date in DB2? Where ps.setDate() comes into picture?
Here I'm having problems. It goes like this:
After validating the date enter by the user in dd-mm-yyyy format, I convert the string date (validatedDate) into java.sql.Date, let' say it sqlDate. Now, when I'm printing sqlDate it is showing entirely different date.
Here is the code:
I cannot guess what is going wrong here in conversion?
IN the above code if we include one more line: df.format(dateString) the datefield from the form is formatted to the required format specified.. then continue coding for storing it in db.
Joined: Sep 16, 2005
Originally posted by Balaji Sampath: IN the above code if we include one more line: df.format(dateString) the datefield from the form is formatted to the required format specified.. then continue coding for storing it in db.
Doesn't format take a Date object, not a String?
Consider doing the following to go from "dd-MM-yyyy" to java.util.Date.
Are you out of the woods? I'm not sure, because you may have to set the time zone of your DateFormat's time zone to, say, UTC.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: validating Date field and saving into DB?