Win a copy of Practical SVG this week in the HTML/CSS/JavaScript 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.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!