Java :
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -1);
Date time = calendar.getTime();
String timeStr = new SimpleDateFormat("yyyy-MM-dd 00:00:00").format(time);
System.out.println(timeStr);
MySQL :
select timestamp(date_add(curdate(), interval - 1 day));
以上两者的获取结果都是:
2020-11-12 00:00:00