• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SimpleDateFormat not returning expectec output?

 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the API more closely. What's the format symbol for a two digit month? (Hint: it isn't "mm")
 
joy b chakravarty
Ranch Hand
Posts: 62
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh ! Thanks Darryl Burke . Its MM instead of mm. Thanks again.
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks joy b chakravarty
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic