Getting classCast Exception | Community
Skip to main content
akhilraj
New Participant
May 4, 2022
Solved

Getting classCast Exception

  • May 4, 2022
  • 1 reply
  • 664 views

Hi, We have a code snippet,

 

 Map<String, Object> assetMeta = damAsset.getMetadata();
boolean isActiveAsset;

boolean hasOnTime = (assetMeta.get("idam:offTime") != null);
boolean hasOffTime = (assetMeta.get("idam:onTime") != null);

Date offTimeDate = hasOnTime ? ((XMPDateTime) assetMeta.get("idam:offTime")).getCalendar().getTime() : null;
Date onTimeDate = hasOffTime ? ((XMPDateTime) assetMeta.get("idam:onTime")).getCalendar().getTime() : null;


Basically it is getting on and off time of an asset. But the casting in line 5 and 6 is providing class cast exception. Please suggest a way to get rid of the same?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Anish-Sinha

hi @akhilraj ,

Check some of the examples of similar case here - https://www.tabnine.com/code/java/methods/com.day.cq.dam.api.Asset/getLastModified

 

1 reply

Anish-Sinha
Anish-SinhaAccepted solution
Employee
May 4, 2022