public static Object financialDuration(Object[] args, XelContext ctx) {
Date settle = UtilFns.stringToDate(args[0].toString());
Date maturi = UtilFns.stringToDate(args[1].toString());
if(settle.after(maturi))
{
throw new SSErrorXelException(SSError.NUM);
}
double coupon = CommonFns.toNumber(args[2]).doubleValue();
double yld = CommonFns.toNumber(args[3]).doubleValue();
if(!(yld > 0 || coupon > 0 ))
{
throw new SSErrorXelException(SSError.NUM);
}
int freq = 1;
try{
freq = CommonFns.toNumber(args[4]).intValue();
}catch(ClassCastException e){
throw new SSErrorXelException(SSError.NUM);
}
if( freq != 1 && freq != 2 && freq != 4 )
{
throw new SSErrorXelException(SSError.NUM);
}
int basis = 0;
if(args.length == 6)
{
try{