Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validating Time Format (HH:MM:SS)

 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I m trying to validate Time which is HH:MM:SS format. But not able to do it.

Suppose input = 34:67:78
String pat = " ( [0-1]+[0-9]+) |([2][0-3]+) : ( [0-5]+[0-9]+) : ([0-5]+[0-9]+ ) ";
Pattern p = Pattern.compile(pat);

Its validating this input...

Plzz tell me wat is wrong in this ???
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The + after the [] is making one or more cases. Remove + it will work.

More inputs are welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic