• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date validation. HELP!!  RSS feed

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the way to validate a date? Java seems to be treating 32nd Jan as 1st Feb. How can I catch a wrong day/month?
Thanks in advance.
 
Trailboss
Posts: 22636
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay, I have some classes I could post that should solve your problem.
I have a class called JDate and GDate (for julian and gregorian formats respectively. Put your date into the GDate type and then pass it to JDate.isValid(). JDate has gregorian to julian conversion stuff built in so it was a snap to add the test.
If this code will be of help to you, let me know and I'll post it here on the ranch.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
paul thanks...
i did some research though and found that the solution is simple. the setLenient method of the dateformat and calendar classes serves the purpose easily.
thanks again.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!