I need to subtract several months of time from a java.util.Date object to get a different java.util.Date. I know that there is a simple way to do this in java 8, however this must be run on my school's server that does not support java 8. My current solution looks like this:
int numDaysToSubtract = 60;
Date curDate = new Date();
//subtract numdays * hours/day * mins/hour * secs/min * millisecs/sec
Date newDate = new Date(curDate.getTime() - (numDaysToSubtract * 24 * 3600 * 1000));
curDate is 4/12/2018 and the calculated newDate is 4/2/2018, which is clearly not 60 days before 4/12/2018.
Why isn't this working as expected?
What should I try instead?