By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,819 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,819 IT Pros & Developers. It's quick & easy.

[Urgent] validating Date field and saving into DB?

P: n/a
Hi,

There is a date field in JSP form where user will enter date in
dd-mm-yyyy format. Now before saving into DB2, I want to validate the
date format against dd-mm-yyyy format and then save into DB2.

I've tried reading SimpeDateFormat and other date format classes, but
couldn't understand. It will be great if somebody tell the following
with code.

1. How to validate Date so that it should satisfy dd-mm-yyyy format?
2. How to insert validated Date in DB2? Where ps.setDate() comes into
picture?

Note: The date column in DB2 is of type "DATE".

Bye,
Viki.

Dec 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You could have DB2 attempt to convert the date and trap the resulting
error when the format is invalid but that's a very slow and inneficient
way to validate dates.

DB2 will accept dates in multiple formats. There is a default for your
database or you can specify the formatting using specific formats such
as "ISO".

If you are interested in using Java to validate the date, then look at
the SimpleDateFormat class documentation. If you can't figure out how to
use it, then I'd recommend asking this question to a Java group.

Phil Sherman
vi***********@gmail.com wrote:
Hi,

There is a date field in JSP form where user will enter date in
dd-mm-yyyy format. Now before saving into DB2, I want to validate the
date format against dd-mm-yyyy format and then save into DB2.

I've tried reading SimpeDateFormat and other date format classes, but
couldn't understand. It will be great if somebody tell the following
with code.

1. How to validate Date so that it should satisfy dd-mm-yyyy format?
2. How to insert validated Date in DB2? Where ps.setDate() comes into
picture?

Note: The date column in DB2 is of type "DATE".

Bye,
Viki.

Dec 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.