Use the setLenient(false) method in SimpleDateFormat.  Actually it's a
method in the DateFormat superclass.  There is a lot of info about dates in
this faq:

http://www.java.sun.com/people/linden/index.html#Date
<http://www.java.sun.com/people/linden/index.html#Date>

Zol Heyman

                -----Original Message-----
                From:   Jeetandra Mahtani [mailto:[EMAIL PROTECTED]]
                Sent:   Thursday, June 03, 1999 7:47 AM
                To:     [EMAIL PROTECTED]
                Subject:        converting to Julian Dates

                Hello,
                I have a form in which a user enters a date in the format
mm/dd/yy.
                Now, the servlet that takes the input from this form,
converts it to a Julian
                Date(yyyyMMdd) before storing it in a table.
                I have been doing this by the following:
                ..
                SimpleDateFormat dat = new SimpleDateFormat("yyyyMMdd");

                String date1 = req.getParameterValues("indate")[0];
                Date date2 = new Date(date1);
                date1 = dat.format(date2);
                ..
                and now date1 contains the format in yyyyMMdd. Fine, but if
the user enters a date that is
                invalid like 02/32/99, it doesn't catch an exception but
returns
                19990304.
                Is there any way by which I could catch an exception so that
I could inform the user that
                the date is invalid.
                Thanks



                _________________________________________________________
                Do You Yahoo!?
                Get your free @yahoo.com address at http://mail.yahoo.com


___________________________________________________________________________
                To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body
                of the message "signoff SERVLET-INTEREST".

                Archives:
http://archives.java.sun.com/archives/servlet-interest.html
                Resources:
http://java.sun.com/products/servlet/external-resources.html
                LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to