Menu

#204 Incorrect DMI error message for Date.setDate()

closed-fixed
None
5
2006-03-29
2006-03-29
Anto paul
No

Hi,
FindBugs is displaying incorrect message for the
bug DMI_BAD_MONTH. (DMI: Passes a constant value for a
month outside of the expected range of 0..11). The
message is given for followng piece of code where it
calls the setDate() method on a java.util.Date object.

today.setDate(16);

Actually this error is to be given for setMonth().

FindBugs 0.9.6 is used.

The full source code is given below.

import java.util.Date;
import java.util.Calendar;

public class TestDate {
public static void main(String args[]) {
Date today = Calendar.getInstance().getTime();
System.out.println(today);
today.setDate(16);
System.out.println(today);
}
}

I am attaching the saved bug report.

Regards,
Anto Paul

Discussion

  • Anto paul

    Anto paul - 2006-03-29

    Saved bug

     
  • Dave Brosius

    Dave Brosius - 2006-03-29

    Logged In: YES
    user_id=66596

    thanks for the report, was checking for setDate, when should
    have been checking for setMonth.

    fixed in cvs

     
  • Dave Brosius

    Dave Brosius - 2006-03-29
    • assigned_to: nobody --> dbrosius
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB