OK, so this is a bit complicated to unpick.
On the LHS (left hand side) of the >=
expression we have:
new Date().getTime() - targetDate
The type of that expression is long
because targetDate
is declared as long
.
On the RHS we have:
threshold * 24 * 60 * 60 * 1000
That is an int
because all of the operands are int
s.
However that expression is likely to overflow. The value of 24 * 60 * 60 * 1000
is a "rather large", and when you multiply it by threshold
, the resulting value is liable to be too big to represent as an int
. If it does overflow, then the result will be truncated, and the >=
test will give the wrong result.
So ... the compiler is suggesting that you should do the RHS calculation using long
arithmetic. The simple way would be to declare threshold
as a long
. But you could also cast it to a long
as in:
((long) threshold) * 24 * 60 * 60 * 1000