RE: Date parsing

2005-03-08 Thread George Sexton
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:[EMAIL PROTECTED] 
 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Date parsing

2005-03-08 Thread Charles P. Killmer
This has a bunch of useful methods in it.  Thank you.

However what I am looking for is some class that can handle a date/time
string in many different formats and return a date/time object back to
me.  I tried your code with 3/1/2005 and it worked fine.  3-1-2005 did
not.  This probably means that locale change is required.  Also I tried
3/1/2005 11:45 am, and that failed as well.  I am assuming this code was
not meant to handle time as well as the date portion.

Am I using your code incorrectly, or should I be looking at some other
code?

Thank You
Charles 

-Original Message-
From: George Sexton [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 08, 2005 9:39 AM
To: 'Tomcat Users List'
Subject: RE: Date parsing

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/SaneDat
e.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:[EMAIL PROTECTED]
 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Date parsing

2005-03-08 Thread George Sexton
Well because of the ambiguities you have to have some expectation of what
format the date will be in.

What date is 05/12/2005? In the US its May 12th. In Britain it's December
5th. You have to have some expectation and validate against it. 

The software is designed to use a Locale as an aid to parsing to set up the
expectation. In our software, we use the browser's accept-language to
retreive a locale.

The class as designed doesn't handle times. It's strictly a date class. Im
thinking about writing a date/time class, but haven't yet.

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

 -Original Message-
 From: Charles P. Killmer [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, March 08, 2005 10:16 AM
 To: Tomcat Users List
 Subject: RE: Date parsing
 
 This has a bunch of useful methods in it.  Thank you.
 
 However what I am looking for is some class that can handle a 
 date/time
 string in many different formats and return a date/time object back to
 me.  I tried your code with 3/1/2005 and it worked fine.  3-1-2005 did
 not.  This probably means that locale change is required.  
 Also I tried
 3/1/2005 11:45 am, and that failed as well.  I am assuming 
 this code was
 not meant to handle time as well as the date portion.
 
 Am I using your code incorrectly, or should I be looking at some other
 code?
 
 Thank You
 Charles 
 
 -Original Message-
 From: George Sexton [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, March 08, 2005 9:39 AM
 To: 'Tomcat Users List'
 Subject: RE: Date parsing
 
 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/dat
 es/SaneDat
 e.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:[EMAIL PROTECTED]
  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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Date parsing

2005-03-07 Thread Derrick Koes

You could do regular expression field validation.  That is, client-side 
(javascript), build a regular expression object that finds a match for many 
formats and run the test function on the input string.  If true, a match was 
found, and hence a legal date.  The downside is that if you have many date 
formats, your regular expression could get pretty ugly.  Here's the appropriate 
documentation for IE jscript.  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsjsgrpregexpsyntax.asp

-Original Message-
From: Charles P. Killmer [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 07, 2005 1:17 PM
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]