public static String getDateBefore(int day) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar now = Calendar.getInstance();
now.setTime(new Date());
now.add(Calendar.DATE, day); //day=-1表示得到昨天日期
return sdf.format(now.getTime()) ;
}