This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java(DATE)Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java(DATE)Validation" Watch "java(DATE)Validation" New topic
Author

java(DATE)Validation

shabarish vai
Ranch Hand

Joined: May 26, 2008
Posts: 79
Date invalidDt = 2008/34/21;
String dateformat = "yyyyMMdd";
Date d=null;
try {
SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
sdf.setLenient(false);
sdf.format(invalidDt);
} catch (Exception e) {
System.out.println(e.getMessage());
}
i got the output when i have "invalidDt" as String but i want "invalidDt" to be date as declared above.
please help.

thanks
Shabarish
Paul Fairhurst
Greenhorn

Joined: Jun 12, 2008
Posts: 7
In Java, the compiler would really like to treat 2008/34/21 as a mathematical expression: 2008 divided by 34 divided by 21.
Try,


[ June 17, 2008: Message edited by: Paul Fairhurst ]

<a href="http://www.infoQuanta.com" target="_blank" rel="nofollow">infoQuanta</a> - parallel java programming made simple
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: java(DATE)Validation
 
It's not a secret anymore!