package com.imsl.test.example.finance; import com.imsl.finance.*; import java.text.*; import java.util.*; /** *

Computes the yield for a 1 year treasury bill.

* * The yield for a 1 year Treasury bill is returned in this example. * @see Code * @see Output */ public class BondTbillyieldEx1 { 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 price = 94.93; double tbillyield = Bond.tbillyield(settlement, maturity, price); System.out.println("The yield for the T-bill is " + tbillyield); } }