当前日期:
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
Date date = new Date();
String yesterday = df.format(date);
System.out.println(yesterday);// new Date()为获取当前系统时间
前一天日期:
Calendar calendar = Calendar.getInstance();
Date date = new Date();calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);date = calendar.getTime();
System.out.println(date);