File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "date" Watch "date" New topic
Author

date

Jackie Wang
Ranch Hand

Joined: Apr 18, 2002
Posts: 315
I guess this question was asked before.
How I can check the validation of date?
says:
A string
"8/4/02" or "09/11/2002" is valid
while
"08042002" or "02/31/2002" is invalid?
Jackie Wang
Ranch Hand

Joined: Apr 18, 2002
Posts: 315
I don't know whether this will help
java.text.DateFormat.getDateInstance().parse(dateString) throws a ParseException
but i don't know how to use it.
Any one can help? Thanks! =)
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
You use it exactly as you wrote it. dateString is the date you want to check. If the date can not be converted into a valid date, it throws a parse exception. If you want the date to be in a specific format in order to be determined to be valid then you can use the SimpleDateFormat class to define a format.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jackie Wang
Ranch Hand

Joined: Apr 18, 2002
Posts: 315
thanks tom, but anything wrong w/ that, and how can i modify as a method which only return a boolean? thanks
Jackie Wang
Ranch Hand

Joined: Apr 18, 2002
Posts: 315
i think this class is working. but instead of throwing exception from a class, I just want a method returning a boolean. Is that possible? Thanks!
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Sure!

[ September 11, 2002: Message edited by: Thomas Paul ]
Jackie Wang
Ranch Hand

Joined: Apr 18, 2002
Posts: 315
got it. thanks tom, i appreciated it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: date
 
Similar Threads
how to update one column of my table?
Date & time operation
Sorting Collection of ArrayList
Extracting year in MM/dd/yyyy
Date range