• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java(DATE)Validation

 
shabarish vai
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic