on 07-23-2014 2:45 PM
Hi,
We have a requirement to populate Retention Date of MA with Expiration Date + 6 years.
I have written an explicit script but it is throwing the following exception. Could you please let me know how to fix this.
Target exception: java.lang.ClassCastException: Illegal cast. Cannot cast java.util.Date to com.sap.odp.api.common.types.SysDateIfc
Here I am giving the code for your reference
SysDateIfc expirationDateIfc=contractobj.getExpirationDate();
Date expirationDate = contractobj.getExpirationDate().getDate();
Calendar c = Calendar.getInstance();
c.setTime(expirationDate);
c.add(Calendar.YEAR, 6);
Date newexpirationDate = c.getTime(); // it is working fine till this point
SysDateIfc retensionDateIfc= (SysDateIfc) newexpirationDate;// This part of code is throwing the ClassCastException
Any inputs are greatly appreciated.
Many Thanks,
Srini
Hi Srini,
SysDateIfc retensionDateIfc= (SysDateIfc) newexpirationDate;
//Instead of the above code please try this:
import com.sap.odp.api.common.types.TypeFactory;
SysDateIfc retensionDateIfc= TypeFactory.createSysDate(newexpirationDate);
//Syntax is like createSysDate(java.util.Date date)
Hope it helps.
Kushagra A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.