package com.imsl.test.example.finance; import com.imsl.finance.*; import java.text.*; import java.util.*; /** *
* Computes the number of days from the beginning of the period to the * settlement date. *
* * This example calls the methodBond.coupdaybs()
* (Bond)
* to calculate the
* number of days from the beginning of the period to the settlement date.
*
* @see Code
* @see Output
*/
public class BondCoupdaysbsEx1 {
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;
int coupdaybs = Bond.coupdaybs(settlement, maturity, freq, dcb);
System.out.println("The number of days from the beginning of the"
+ "\ncoupon period to the settlement date is " + coupdaybs);
}
}