• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

add method of Calendar

 
Dorcas Rebanha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this code:

Calendar oneYearLater = new GregorianCalendar();
oneYearLater.add(Calendar.YEAR, 1);

The first line gets today's date. The second line should change the value, but it isn't doing it.

I am running Drools in debug mode, and the value of the field doesn't change from one line to the next. What am I doing wrong?

I have also tried this:

Calendar oneYearLater = new GregorianCalendar(2108, 9, 24);

The result that shows in the debug Variables display area looks pretty random to me. When I look at the values, cdate is null, and gdate has a cachedYear of 2004, while the dayOfMonth, Month and Year are all 0. Again, what am I doing wrong?

Thanks for any help.
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you exactly check that nothing happens?

I tried your code with some print statements in between:

The output is just as expected:
 
Dorcas Rebanha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Verrry innnteresting. Printing the field as you suggested had the same results that you showed, that is, the field changed as it was supposed to.

But the variable display area of the debug mode showed that the field did NOT change.

This tells me that my question is not about making the code work right, but it's really about making the environment work right, so the code will do what it is supposed to do. Or that I need to understand the environment, and how to interpret what debug is telling me. I'll go to the experienced folks around here for that.

Thanks for your help.

Dorcas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic