Example: Bond Yield - Odd Long Last Coupon

This example calculates the yield of an odd long last coupon with multiple coupon periods to redemption.
Settlement 02/25/1993
Maturity 09/15/2004
Last Coupon 12/15/2003
Rate 0.06875
Price 85.334452
Redemption Value 100.0
Payment Frequency Bond.SEMIANNUAL
Day Count Basis DayCountBasis.Basis30e360

import com.imsl.finance.*;
import java.text.*;
import java.util.*;

public class OddLongLastMultiCoupYieldEx {

    static final DateFormat dateFormat
            = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);

    static private GregorianCalendar parse(String s) throws ParseException {
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(dateFormat.parse(s));
        return cal;
    }

    public static void main(String args[]) throws ParseException {
        GregorianCalendar settlement = parse("02/25/1993");
        GregorianCalendar maturity = parse("09/15/2004");
        GregorianCalendar lastCoupon = parse("12/15/2003");
        double yield = Bond.yield(settlement, maturity, lastCoupon, 0.06875,
                85.334452, 100.0, Bond.SEMIANNUAL,
                DayCountBasis.Basis30e360);
        System.out.println("The yield is " + yield);
    }
}

Output

The yield is 0.0892999995362467
Link to Java source.