The moose likes Java in General and the fly likes Date Format Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Date Format Issue" Watch "Date Format Issue" New topic
Author

Date Format Issue

Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
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

Joined: Jul 20, 2006
Posts: 53
You can use regular expression or put validation separately for days, month and year.

~Ravi
Ganesh Shirsat
Ranch Hand

Joined: Jan 10, 2010
Posts: 30

Hi,

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32694
    
    4
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

Joined: Aug 18, 2010
Posts: 62
It works.Thanks a lot.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32694
    
    4
Well done What works? setLenient{false} or something different?
Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
Sorry for the delayed reply
code given by Ganesh works for me. Thanks again for Ganesh.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Date Format Issue
 
Similar Threads
convert a string to java.sql.Date object
string to date parsing ....
Java date conversion confusion...
Code review required for converting dateformat
String GMT Date conversion to EST/EDT