This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Unparseable date exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Unparseable date exception" Watch "Unparseable date exception" New topic

Unparseable date exception

Divya Sanjeev

Joined: Dec 16, 2009
Posts: 18
Hi All,

I tried this piece of code but it is giving me Unparseable date exception. Can you please help me out?

Mala Gupta
Ranch Hand

Joined: Sep 27, 2002
Posts: 251

Please use the code tag to post your tag. This tag retains the code indentation.

The format of your date 'dd-MMM-yyyy' does not matches with the exact value that you pass to it, i.e., '21JUN2010'. Either remove hyphens from the date format, or add hyphens to the actual date value.

Date format 'dd-MMM-yyyy' will correctly parse value '21-JUN-2010'. And Date format 'ddMMMyyyy' will correctly parse value '21JUN2010'


Author of Manning's OCA Java SE 7 Programmer I Certification Guide and OCP Java SE 7 Programmer II Certification Guide
Divya Sanjeev

Joined: Dec 16, 2009
Posts: 18
Hi Mala,

Thanks a lot for the suggestion. I had missed hyphen in the date format.

I agree. Here's the link:
subject: Unparseable date exception
It's not a secret anymore!