File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Validating Dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Validating Dates" Watch "Validating Dates" New topic
Author

Validating Dates

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
I am writing a program that accepts dates as a parameter and then validates the date so that 10th of October 2007 should be entered as 20071010. I wrote a probram to validate this but it's not working ok



any suggestions would be appreciated
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18986
    
    8

"yyyyddMM"
Year, Day, Month? Well, that would work okay for October 10 (day = month) but not so well for other choices.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> but it's not working ok

looks like you need to create the SimpleDateFormat object first
set its leniency to false sdf.setLenient(false);
then parse the date
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Originally posted by Michael Dunn:
> but it's not working ok

looks like you need to create the SimpleDateFormat object first
set its leniency to false sdf.setLenient(false);
then parse the date


Thats what i finally did and now it works perfectly
my code is
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating Dates