File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes SimpleDateFormat not returning expectec output? 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 "SimpleDateFormat not returning expectec output?" Watch "SimpleDateFormat not returning expectec output?" New topic
Author

SimpleDateFormat not returning expectec output?

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi all, I am converting string to date . following is my code but it is not returning expected output.



and it returns output as :

Converted date isThu Jan 20 16:11:00 IST 2011


But I think output must be as

Converted date isThu Jun 20 16:11:00 IST 2011


Why it shows month as Jan instead of Jun?


Life is easy because we write the source code.....
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4164
    
    3

Read the API more closely. What's the format symbol for a two digit month? (Hint: it isn't "mm")


luck, db
There are no new questions, but there may be new answers.
joy b chakravarty
Ranch Hand

Joined: May 16, 2011
Posts: 62

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");

you've used 'mm' for both minutes and month
'MM' stands for month and 'mm' stands for minutes


Cheers, Joy [SCJP 1.4, SCBCD 5.0]
get high on alcohol, algorithm or both
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Oh ! Thanks Darryl Burke . Its MM instead of mm. Thanks again.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Thanks joy b chakravarty
 
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: SimpleDateFormat not returning expectec output?
 
Similar Threads
converting string yyyy/MM/dd to java.util.Date
Problems handling the Date Class.
Xml Parsing
Date conversions
Convert String to Date format