Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, -1);
//前一天
String QYTDATE = format.format(cal.getTime());
Calendar cal1 = Calendar.getInstance();
//当前日期
cal1.setTime(date);
String DQDATE= format.format(cal1.getTime());
JAVA 获取当前日期和前一天的日期
最新推荐文章于 2024-10-12 15:31:46 发布