java - Android get date before 7 days (one week) - Stack Overflow
Parse the date:
DatemyDate =dateFormat.parse(dateString);
And then either figure out how many milliseconds you need to subtract:
DatenewDate =newDate(myDate.getTime()-604800000L);// 7 * 24 * 60 * 60 * 1000
Or use the API provided by the
java.util.Calendar
class:Calendarcalendar =Calendar.getInstance();calendar.setTime(myDate);calendar.add(Calendar.DAY_OF_YEAR,-7);DatenewDate =calendar.getTime();
Then, if you need to, convert it back to a String:
Stringdate =dateFormat.format(newDate);