Hi, We have below code,
Map<String, Object> assetMeta = resourceResolver.getResource(hit.getPath()).adaptTo(Asset.class).getMetadata();
Calendar expireDateCal = (assetMeta.get("idam:offTime") != null) ? ((XMPDateTime) assetMeta
.get("idam:offTime")).getCalendar() : null;
Calendar ontimeCal = (assetMeta.get("idam:onTime") != null) ? ((XMPDateTime) assetMeta
.get("idam:onTime")).getCalendar() : null;
But while executing we are getting below error,
java.lang.ClassCastException: class com.adobe.xmp.impl.XMPDateTimeImpl cannot be cast to class com.adobe.xmp.XMPDateTime (com.adobe.xmp.impl.XMPDateTimeImpl is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @4ef19625; com.adobe.xmp.XMPDateTime is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @3e5c6a97)
How we can resolve ClassCastException for XMPDateTime?
Views
Replies
Total Likes
Any reply is helpful
Views
Replies
Total Likes
Casting is the process of type conversion, which is in Java very common because its a statically typed language. Type Casting only works when the casted object follows an is a relationship to the type you are trying to cast to. ClassCastException is a runtime exception raised in Java when you try to improperly cast a class from one type to another. It's thrown to indicate that the code has attempted to cast an object to a related class, but of which it is not an instance. It is good practice to guard any explicit casts with an instanceof check first:
if (myApple instanceof Fruit) {
Fruit myFruit = (Fruit)myApple;
}
In general, that's what a cast means: it tells the compiler that even though this assignment might fail, you're pretty certain that it won't. In exchange for allowing the code to compile, you assume the risk of a run-time exception.
Here are some basic rules to keep in mind when casting variables:
Views
Replies
Total Likes
Hi,
Administrators permit us to perform different numerical and consistent capabilities, such as adding and looking at numbers. Every administrator in an articulation is assessed in a foreordained request, known as administrator priority. Learn it from Java Classes in Pune.
Views
Replies
Total Likes