File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Parsing dates with dashes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing dates with dashes" Watch "Parsing dates with dashes" New topic

Parsing dates with dashes

Tarek Nabil

Joined: May 07, 2005
Posts: 1
Hi everyone,

This might sound like a trivial problem, I personally never thought I would have a problem parsing dates, but it seems like the SimpleDateFormat class does not like dashes.

SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");

java.text.ParseException: Unparseable date: "24-09-1976"

at java.text.DateFormat.parse(

at test.TestMisc.testDateParse(

at test.TestMisc.main(

Please help.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i found no prob whatsoever:

Fri Sep 24 00:00:00 BST 1976

java amateur
Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
Even I didn't find any problem when I replied to the same question on Sun's forum. Maybe there is some older class file creating the problem.

Cheers!<br /><b>Annie</b>
I agree. Here's the link:
subject: Parsing dates with dashes
It's not a secret anymore!