The pattern you're passing to compile is a regular expression; it's a string matching tool. Pattern doesn't look at is as a Date format but as a regular expression
That's why it's not matching.
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35242
7
posted
0
You're confusing regular expression patterns with the patterns used by the DateFormat classes. The regexp pattern would be something like "[0-3]\\d-[01]\\d-[0-2]\\d{3}-[0-2]\\d:[0-5]\\d:[0-5]\\d". Have a look at the javadocs of the java.util.regex.Pattern class for details.
If you want to check that a string is a valid date/time pattern, have a look at the java.text.SimpleDateFormat.parse method.
Ulf , you are correct.I know that. But i wonder why this pattern is not working .this is also java standard pattern and best suited for the dateformat.
luck, db
There are no new questions, but there may be new answers.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35242
7
posted
0
this is also java standard pattern
There is no such thing as a "Java standard pattern". Regular expressions use one kind of pattern, date formats use a different one, PrintStream.printf uses yet another format, etc. None of these formats have anything to do with the other ones, and can't be used interchangeably with any of them. [ May 06, 2008: Message edited by: Ulf Dittmer ]