bug

A discussion forum for the JCommon class library.
Locked
joseph

bug

Post by joseph » Fri Jan 18, 2002 4:02 pm

Hello I m currently testing your library for using it in a financial back office and I found a bug (maybe not a bug but I don t use correctly the library) there are the source code :

import com.jrefinery.ibd.SimpleBusinessDayCalendarModel;
import com.jrefinery.ibd.io.CalendarRuleParser;
import com.jrefinery.ibd.io.GeneralLexer;
import com.jrefinery.date.SerialDate;

import com.jrefinery.finance.data.reference.BusinessDayCalendar;

import java.io.FileInputStream;
import java.io.File;
import java.io.FileNotFoundException;

import java.util.Date;

public class TestDay
{

private BusinessDayCalendar getBusinessCalendar(String name)
{
BusinessDayCalendar calendar = null;

try
{
SimpleBusinessDayCalendarModel calendarModel = new SimpleBusinessDayCalendarModel();
File file = new File("C:\Dev\Travail\BackOffice\project\driver\ibd-1.2.1\data\holidays.txt");
GeneralLexer lexer = new GeneralLexer(new FileInputStream(file));
CalendarRuleParser parser = new CalendarRuleParser(lexer);
parser.readCalendarsIntoModel(calendarModel);
calendar = calendarModel.getBusinessDayCalendar(name);
}catch(FileNotFoundException fnfe)
{
fnfe.printStackTrace();
}catch(Exception e)
{
e.printStackTrace();
}

return calendar;
}

private SerialDate addXBusinessDay(SerialDate serialDate, int nDays, BusinessDayCalendar calendar)
{
int i = 1;

while(true)
{
serialDate = serialDate.addDays(1, serialDate);

if (calendar.isBusinessDay(serialDate))
{
System.out.println("The : " + serialDate.toString() + " is a business day." + " Count : " + i);
}else
{
System.out.println("The : " + serialDate.toString() + " is a non business day." + " Count : " + i);
}
i++;
}

return null;
}

public TestDay()
{
BusinessDayCalendar calendar = this.getBusinessCalendar("London, United Kingdom");
Date date = DateTransformer.getCurrentDate();
SerialDate newDate = this.addXBusinessDay(SerialDate.createInstance(date), 3, calendar);
}

public static void main(String[] args)
{
TestDay testDay1 = new TestDay();
}
}

Locked