Forums Register Login

Validating Dates

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

"yyyyddMM"

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

+Pie Number of slices to send: Send
> 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
+Pie Number of slices to send: Send
 

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
We don't have time for this. We've gotta save the moon! Or check this out:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1687 times.
Similar Threads
Conversion of string to date
timespan false?
"date" sorting program
Unparseable date exception
Problem with javascript dates
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:15:14.