• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validating Dates

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21111
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic