Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Format Issue

 
Ragupathirajan Venkatesan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I am having the string date value and I want to convert that as java date value by using the SimpleDateFormate. But it is not highlighting the wrong date. for example.


above code is producing the output like Date: Thu Dec 13 00:00:00 IST 2012. I want to identify the incorrect format relevent to dd/MM/yyyy. Please suggest. Thanks in advance.
 
Ravishanker kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use regular expression or put validation separately for days, month and year.

~Ravi
 
Ganesh Shirsat
Ranch Hand
Posts: 33
Google Web Toolkit Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
13/24/2011 is being parsed "leniently", so December + 12 months is December next year.

Have a look through all the classes you are using and see whether they have a setLenient(false) method. See whether that would help.
 
Ragupathirajan Venkatesan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works.Thanks a lot.
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done What works? setLenient{false} or something different?
 
Ragupathirajan Venkatesan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the delayed reply
code given by Ganesh works for me. Thanks again for Ganesh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic