Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

convert String to Date  RSS feed

 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!