Example: Next Coupon Date After the Settlement Date

In this example, the settlement date is 11/11/86. The previous coupon date before this date is returned.

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

public class coupncdEx1 {

    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("11/11/86");
        GregorianCalendar maturity = parse("3/1/99");
        int freq = Bond.SEMIANNUAL;
        DayCountBasis dcb = DayCountBasis.BasisActual365;
        GregorianCalendar coupncd = Bond.coupncd(settlement, maturity,
                freq, dcb);
        System.out.println("The next coupon date after the settlement date is "
                + dateFormat.format(coupncd.getTime()));
    }
}

Output

The next coupon date after the settlement date is 3/1/87
Link to Java source.