import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class test2 {
public static void main(String[] args) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(new Date());
Date end = c.getTime();
String dqrq= format.format(end);//当前日期
System.out.println(dqrq);
c.add(Calendar.DATE, -1);
Date start = c.getTime();
String qyt= format.format(start);//前一天
System.out.println(qyt);
c.add(Calendar.MONTH, -1);
Date start1 = c.getTime();
String startDay = format.format(start1);//前一月
System.out.println(startDay);
c.add(Calendar.YEAR, -1);
Date start2 = c.getTime();
String startDay3 = format.format(start2);//前一年
System.out.println(startDay3);
}
}