aspose file tools*
The moose likes Java in General and the fly likes getting wrong values using matcher.group() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "getting wrong values using matcher.group()" Watch "getting wrong values using matcher.group()" New topic
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: 1769
    
    7

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: 4640
    
    5

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: 1769
    
    7

Then you should disable lenient parsing, using the setLenient() method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting wrong values using matcher.group()