package com.imsl.test.example.finance; import com.imsl.finance.*; import java.text.*; import java.util.*; /** *
* Computes the bond-equivalent yield for a treasury bill.
* The bond-equivalent yield for a 1 year Treasury bill is returned in this * example. * * * * @see Code * @see Output */ public class BondTbilleqEx1 { 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("7/1/85"); GregorianCalendar maturity = parse("7/1/86"); double discount = .05; double tbilleq = Bond.tbilleq(settlement, maturity, discount); System.out.println("The bond-equivalent yield for the T-bill is " + tbilleq); } }