LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-30-2006, 11:43 PM   #1
Manashi
LQ Newbie
 
Registered: Jan 2006
Posts: 27

Rep: Reputation: 15
Question Date Validation in java using Patterns


hi...
can anybody provide me with the code to validate date in java using patterns....
i need it urgently...

The pattern i hav used is as follows

dates=in.readLine();
nam=Pattern.matches("[0-3][0-9][/][0|1][0-9|1-2][/][1-2][0-9][0-9][0-9]",dates);


Waithing for the reply
 
Old 07-31-2006, 04:09 AM   #2
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Rep: Reputation: 31
your code works for me at least ...

probably its better for you to tell them whats the problem you encountered ...



//btw ... thanks for leading me towards the possibilities of using Pattern.matches ^_^


.

Last edited by alred; 07-31-2006 at 04:11 AM.
 
Old 07-31-2006, 07:19 AM   #3
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
I know this isn't answering the question that was asked, but bear in mind that formatting dates as numeric dd/mm/yyyy or mm/dd/yyyy leaves you wide open to the possibility of people entering dates the wrong way round, especially if your program is going to be used around the world.

Depending on how important the dates are in your program, I personally would use a foolproof input method such as select lists or a clickable calendar, to avoid that sort of problem.

Sorry if that completely misses the point, or is something you're already aware of, but I thought it was worth saying. (even if it doesn't help you, it might help someone else reading this thread)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java date and time manipulation? trscookie Programming 1 07-13-2006 06:51 PM
simple date validation in PHP tooparam Programming 1 04-08-2006 01:50 PM
Getting Day of Week - Java - SQL Date MRMadhav Programming 4 04-03-2006 12:01 PM
Remembering patterns and printing only those patterns using sed bernie82 Programming 5 05-26-2005 05:18 PM
JavaScript inside a CGI for date validation....doesn't work!! vous Programming 3 08-27-2003 04:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration