java获取当前日前几天
1 /**
2 * 获得当前日期前day天
3 * @param day
4 * @return
5 */
6 public static String getTimeStr(int day) {
7 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
8 Date d = new Date();
9 Calendar cal = Calendar.getInstance();
10 cal.setTime(d);
11 cal.add(Calendar.DATE, -day);
12 String resultDay = df.format(cal.getTime());
13 return resultDay;
14 }