aspose 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


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

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
 
 
subject: SimpleDateFormat not returning expectec output?