Day constructor bug

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Barrie Mulley

Day constructor bug

Post by Barrie Mulley » Thu Feb 14, 2002 1:48 am

It seems that the constructor Minute(Date time) in Minute.java has a bug similar to one described in a previous post concerning a constructor for the Week object. The Day constructor reads:

public Minute(Date time) {

Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int min = calendar.get(Calendar.MINUTE);
this.minute = (hour*60)+min+1;
this.day = new Day(time);

}

Without using the statement "calendar.setTime(time);" after the Calendar object is instantiated the Minute object will be constructed referring to the current time as opposed to the argument time. I noticed this when attempting to add more than one minute object from the same day to a chart and received the error:
"TimeSeries.add(...): time period already exists."

Barrie Mulley

Re: Day constructor bug

Post by Barrie Mulley » Thu Feb 14, 2002 2:22 am

Oops, that topic should read 'Minute' constructor bug. My apologies.

David Gilbert

Re: Minute constructor bug

Post by David Gilbert » Thu Feb 14, 2002 7:55 am

Hi Barrie,

Thanks for the report...there's some cut and pasted code in the Hour, Minute and Second classes, and none of them have been thoroughly tested. I'll review them and apply the appropriate fix...

Regards,

DG.

Locked