private String getStartDate() { Calendar cal = Calendar.getInstance(); // 负数当前时间往前,正数是往后 cal.add(Calendar.DATE, -120); Date d = cal.getTime(); //转换为年月日格式 SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd"); String yesterday = sp.format(d); return yesterday; }