/**
* 获得指定日期的前几天日期
*
* @param specifiedDay 指定日期
* @param pattern 需要返回的日期格式,如yyyy-MM-dd
* @param before 前几天
* @return String
*/
public static String getSpecifiedDayBefore(String pattern, String specifiedDay, int before) {
Calendar c = Calendar.getInstance();
Date date;
String dayBefore = "";
try {
date = new SimpleDateFormat(pattern).parse(specifiedDay);
c.setTime(date);
int day = c.get(Calendar.DATE);
c.set(Calendar.DATE, day - before);
dayBefore = new SimpleDateFormat(pattern).format(c.getTime());
} catch (Exception e) {
//todo
} finally {
return dayBefore;
}
}