public static String getYesterdayStr(){
String yesterday=null;
Calendar calendar = Calendar.getInstance();//此时获取的是系统当前时间
calendar.add(Calendar.DATE, -1); //得到前一天
yesterday= new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
//System.out.println(yesterday);
return yesterday;
}
public static String getBeforeYesterdayStr(){
String beforeyesterday=null;
Calendar calendar = Calendar.getInstance();//此时获取的是系统当前时间
calendar.add(Calendar.DATE, -2);
beforeyesterday= new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
//System.out.println(yesterday);
return beforeyesterday;
}
时间: 2024-10-13 00:59:59