| Author |
getting wrong values using matcher.group()
|
vardhan reddy
Ranch Hand
Joined: Oct 28, 2011
Posts: 42
|
|
Hi All,
I am validating date using regex and I'm trying to get matcher groups and getting wrong values. Can anyone check and let me know what i'm doing wrong.
|
 |
Jelle Klap
Bartender
Joined: Mar 10, 2008
Posts: 1407
|
|
Someone is going to inevitably mention this, so it might as well be me: why not just use (Simple)DateFormat?
|
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
|
 |
vardhan reddy
Ranch Hand
Joined: Oct 28, 2011
Posts: 42
|
|
Hi,
I'm planning to write generic class to validate any date format and DATE_PATTERN regex will be passed to validate method based on date format.
By using DateFormat, if parse (date format yyyymmdd) I will get but which is wrong date(month is wrong).
thanks for your reply.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
vardhan reddy wrote:By using DateFormat, if parse (date format yyyymmdd) I will get but which is wrong date(month is wrong).
No, it's right. What's the 1st day of the 13th month of 2012, with a lenient interpretation?
|
luck, db
There are no new questions, but there may be new answers.
|
 |
vardhan reddy
Ranch Hand
Joined: Oct 28, 2011
Posts: 42
|
|
|
It will give 1st date of next month, but i dont want that date and I want to display warning message 'Invalide date' something like this.
|
 |
Jelle Klap
Bartender
Joined: Mar 10, 2008
Posts: 1407
|
|
|
Then you should disable lenient parsing, using the setLenient() method.
|
 |
 |
|
|
subject: getting wrong values using matcher.group()
|
|
|