SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
Date date = new Date();
System.out.println(df.format(date)); // 当前系统时间
Date newDate = stepMonth(date, 1);
System.out.println("当前时间前1个月的日期:" + df.format(newDate));
public static Date stepMonth(Date sourceDate, int month) {
Calendar c = Calendar.getInstance();
c.setTime(sourceDate);
c.add(Calendar.MONTH, month);
return c.getTime();
}