Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Casting Object to Date

807603Nov 15 2007 — edited Nov 15 2007
I have a
HashMap
I call the get(key) method and this method returns me the Object type.
A field which is Date type whose key is DATE_KEY and when i call get(DATE_KEY) it returns me the Object type but I need to convert it to Date and when i cast it, I get classcast exception. Any clue/solution pls?

Line 1. xxx = xxx.get(DATE_KEY);

xxx.get(DATE_KEY).getClass(),getName() says it is a Date type but when I cast it to date in line 1, it throws classcast exception.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 13 2007
Added on Nov 15 2007
5 comments
1,624 views