If you're dealing with objects of java.util.Date
using the +
operator on those objects isn't valid.
More importantly, even if the +
operator had been legal, it wouldn't make any sense using it - date + 1
should add 1
to the date or month or year..?
To manipulate an object of java.util.Date
the class Calendar
provides several utility methods. One of those which you can use here is Calendar.add
.
Adds or subtracts the specified amount of time to the given calendar
field, based on the calendar's rules. For example, to subtract 5 days
from the current time of the calendar, you can achieve it by calling:
add(Calendar.DAY_OF_MONTH, -5)
Edit:
It appears from your edit that you aren't using java.util.Date
objects. Now that your Date
object maintains three properties (most likely date, month and year), you should be able to apply arithmetic operators on those fields.
However you should be careful to follow date related rules while manipulating those fields (assuming they belong to one of the integral types).
For example adding 1
day to 28/02/2013
should update both date and month of the Date
instance.