mcgettiu
asked on
Validating a date object
Hey guys....
Quick question...is it possible to validate a date object?
So i could throw an exception if date is set to something like 31 Feb 2007???
Thanks a mill
Una
Quick question...is it possible to validate a date object?
So i could throw an exception if date is set to something like 31 Feb 2007???
Thanks a mill
Una
Hi mcgettiu,
You can use the isValid() method on the DateTime object.
Regards
Kelvin
You can use the isValid() method on the DateTime object.
Regards
Kelvin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ajay-Singh
I already have my date object...so do i have to covert this back to a string to the parse method from DateFormat?
KelvinY
What is the DateTime object? I cant find it in the Java API?????
I already have my date object...so do i have to covert this back to a string to the parse method from DateFormat?
KelvinY
What is the DateTime object? I cant find it in the Java API?????
> I already have my date object
what do you mean? You have a date object that represents 31 Feb 2007
what do you mean? You have a date object that represents 31 Feb 2007
>>I already have my date object...so do i have to covert this back to a string to the parse method from DateFormat?
Yes (although i don't know how you got the Date in the first place)
Yes (although i don't know how you got the Date in the first place)
DateFormat format = new SimpleDateFormat("dd MMM yyyy);
format.parse("31 Feb 2007"); // Will throw an exception