• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another format check :P

 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I need to check a String if has the correct date format (DD/MM/YYYY).

I have created



but now i dont know how to compare my String with dateFormat to find if is valid. Also i have to check if DD is from 01-31 MM is from 01-12
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your requirement to check that the string represents an actual date? Or will you accept "31/02/2011" as valid?
 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not the current date, just a date in that format
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checking if a String represents a valid usually means parsing that String into a Date. There are several threads about that; I've posted in quite a few of these already.
And what Paul meant is disallowing invalid dates like February 31st. You can make the date format non-lenient to disallow this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic