You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Charles P. Killmer" <ch...@netgaintechnology.com> on 2005/03/07 19:17:13 UTC

Date parsing

I have an object with a TimeStamp member.  This will be populated by
users of a website and entered into a database.
 
My problem is, I would like to allow the users to enter the date in a
number of formats.  Does anyone have any recommendations aside from
multiple try catch blocks each trying to parse the given date with a
different expected format?
 
Thanks you for any help,
Charles Killmer
 

RE: Date parsing

Posted by George Sexton <gs...@mhsoftware.com>.
I wrote my own date handling class, and it will do what you are looking for:

Essentially, to provide a picture for the users you pass in the locale to
SaneDate.getDateFormat().

To parse the date, 

try {
new SaneDate(request.getParameter("parm"),lc);
} catch (InvalidDateException ide) {
}


http://www.mhsoftware.com/resources/jar/doc/com/MHSoftware/dates/SaneDate.ht
ml

You can download it from:

http://www.mhsoftware.com/bin/MHS.zip


George Sexton
MH Software, Inc.
http://www.mhsoftware.com/
Voice: 303 438 9585
  

> -----Original Message-----
> From: Charles P. Killmer [mailto:charlesk@netgaintechnology.com] 
> Sent: Monday, March 07, 2005 11:17 AM
> To: Tomcat Users List
> Subject: Date parsing
> 
> I have an object with a TimeStamp member.  This will be populated by
> users of a website and entered into a database.
>  
> My problem is, I would like to allow the users to enter the date in a
> number of formats.  Does anyone have any recommendations aside from
> multiple try catch blocks each trying to parse the given date with a
> different expected format?
>  
> Thanks you for any help,
> Charles Killmer
>  
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org