The Base Class "DateFormat" has a SetLenient method, setting it to false disables the described behaviour and rejects out of range elements.
thanks for the reply
-----Original Message-----
From: Nathan, Swami [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 2:49 PM
To: 'Stefan Dingfelder'; Mario Fernandes (IT Dept. - Langley)
Cc: '[EMAIL PROTECTED]'
Subject: RE: Date validationgoto www.codeguru.com - the code is already there for date validation. Hope that helpsThanks, swami-----Original Message-----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)
From: Stefan Dingfelder [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 11:10 AM
To: Mario Fernandes (IT Dept. - Langley)
Cc: '[EMAIL PROTECTED]'
Subject: Re: Date validationRegards,
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 advanceregards
Mario
