Example: Accrued Interest - Payment at Maturity
In this example, the accrued interest is calculated for a bond which pays at maturity. The day count basis used is 30/360.
import com.imsl.finance.*;
import java.text.*;
import java.util.*;
public class accrintmEx1 {
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 issue = parse("10/1/91");
GregorianCalendar settlement = parse("11/3/91");
double rate = .06;
double par = 1000.;
DayCountBasis dcb = DayCountBasis.BasisNASD;
double accrintm = Bond.accrintm(issue, settlement, rate, par, dcb);
System.out.println("The accrued interest is " +accrintm);
}
}
Output
The accrued interest is 5.333333333333334
Link to Java source.