This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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
Pie
Posts: 49733
69
  • 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
Pie
Posts: 49733
69
  • 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