Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing dates with dashes

 
Tarek Nabil
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found no prob whatsoever:

Fri Sep 24 00:00:00 BST 1976
 
Annie Smith
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic