Java gets the current time, subtracts one day from the number of days, and returns Date.

SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
Date beginDate = new Date();
Calendar date = Calendar.getInstance();
date.setTime(beginDate);
date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
Date endDate = dft.parse(dft.format(date.getTime()));

减几天都可以 !

Guess you like

Origin blog.csdn.net/qq_42857603/article/details/108073484