SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // HH 为24小时制 hh 为12小时制
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, -30);//根据实际需要修改
Date date = calendar.getTime();
System.out.println(tempDate.format(date));