I am assuming Java has some built-in way to do this.
Given a date, how can I determine the date one day prior to that date?
For example, suppose I am given 3/1/2009. The previous date is 2/28/2009. If I had been given 3/1/2008, the previous date would have been 2/29/2008.
Use the Calendar interface.
Doing ‘addition’ in this way guarantees you get a valid date. This is valid for 1st of the year as well, e.g. if
myDateis January 1st, 2012,oneDayBeforewill be December 31st, 2011.