Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

convert String to Date

 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I have written a small program that calculate 30 day
old Date from current date.I want a the date to be formatted in MM/dd/yyyy format.Below code is giving ClassCastException at line 1.Not sure wat is wrong.Please correct me.


Thanks

[ March 16, 2006: Message edited by: meena latha ]
[ March 16, 2006: Message edited by: meena latha ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that java.sql.Date extends java.util.Date.

In this example, the true type is java.util.Date (as returned by SimpleDateFormat's parse method), but you're trying to downcast to java.sql.Date.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic