Well, Java does not help you here. In fact you will always get the closest possible date ... (It's the same with Microsoft by the way). The only suitable way I know off is to do the checking on your own. You may find a suitable example on the web (I think that ibm's alphaworks team made a MaskedField that also has a validator for dates within)

Regards,
Stefan.

"Mario Fernandes (IT Dept. - Langley)" wrote:

 

Hi

Can you please tell me how to validate if a date entered is a valid date.
FOr ex an invalid date is 02-29-2001(29 feb 2001). But when creating a date
object using the code below no exception is thrown. It instead turns the date into
01-03-2001.

                java.text.SimpleDateFormat s = new
java.text.SimpleDateFormat ("MM-dd-yyyy");
                java.util.Date d = s.parse(Date, new
java.text.ParsePosition(0));
                Timestamp t = new Timestamp(d.getTime());

I would greatly appreciate an early reply.
Many thanks in advance

regards

Mario

Reply via email to