Checking the Time format..
Hello Friends,
I have a string s ="10:12 PM" (something like this). I want to check that this is the correct format of Time or not. For that I have used the Pattern class of Java and have a code like
Pattern p = Pattern.compile("(\\d)(\\d)(:)(\\d)(\\d)(\\s)(A|P)(M)");
Matcher m = p.matcher("10:20 AM");
boolean b = m.matches();
System.out.println(b);
This code is running perfect, but I want to check for one more thing. I want to check that hours fall in range 0-11 and minutes fall in range 0-59, but pattern class dont have any range check for digit(we can do that on char). Please suggest me a solution.
Thanks,
-Vaibhav-

