aspose file tools*
The moose likes Java in General and the fly likes Date Format Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
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: 32

Hi,

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36574
    
  16
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: 36574
    
  16
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://aspose.com/file-tools
 
subject: Date Format Issue
 
Similar Threads
convert a string to java.sql.Date object
string to date parsing ....
Code review required for converting dateformat
Java date conversion confusion...
String GMT Date conversion to EST/EDT