my dog learned polymorphism*
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing dates with dashes" Watch "Parsing dates with dashes" New topic
Author

Parsing dates with dashes

Tarek Nabil
Greenhorn

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");
System.out.println(format.parse("24-09-1976"));

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

at java.text.DateFormat.parse(DateFormat.java:319)

at test.TestMisc.testDateParse(TestMisc.java:12)

at test.TestMisc.main(TestMisc.java:21)

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>
 
wood burning stoves
 
subject: Parsing dates with dashes