• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date parsing error..???  RSS feed

 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a string coming in the format OCT/15/2004.
I have to convert this in to a date object.
I am using th following code:
SimpleDateFormat sdf = new SimpleDateFormat("MMM/DD/yyyy");
value="Jul/13/2004";
sdf.parse(value));
Here value is OCT/15/2004.
The date object i get is Jan/13/2004.
No matter what month is passed the parsed date object always has the month as Jan.
What is going wrong?
 
Joe Ess
Bartender
Posts: 9441
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works fine for me.



 
Pavan Panduga
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gaurav,

take a look at javadoc of SimpleDateFormat for defined formats.



new SimpleDateFormat("MMM/DD/yyyy"); is different from
new SimpleDateFormat("MMM/dd/yyyy");

hope this helps,
Pavan
 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it worked for me now.
dd instead of DD did the trick
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!