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 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 agree. Here's the link: http://aspose.com/file-tools
 
subject: java(DATE)Validation
 
Similar Threads
convert timestamp to date
Date format
Grouse about Calendar, DateFormat, Date
Date format question
How to print default date in required format