Skip to content

Commit

Permalink
[JENKINS-32651] Fix calculation of report begin date
Browse files Browse the repository at this point in the history
Currently, computation is done using Calendar.roll() which is wrong.
roll() only changes a specific unit and doesn't update larger fields.
For example, rolling back 2 week on the first week of a month sets
the calendar week to the last week of the month, which is in the future.
Obviously, when the begin date is in the future, there's nothing in the
report.

Using Calendar.add() with a negative value substracts the right amount
of time from the current time.
  • Loading branch information
ydubreuil committed Jan 27, 2016
1 parent ba4ef5c commit 3b10254
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -82,7 +82,7 @@ public Long getStartDate(int range, String rangeUnits){
iUnits = Calendar.YEAR;
}
Calendar tmpCal = Calendar.getInstance();
tmpCal.roll(iUnits, iRange);
tmpCal.add(iUnits, iRange);
return new Long(tmpCal.getTimeInMillis());
}

Expand Down

0 comments on commit 3b10254

Please sign in to comment.