java获取指定日期的前几天时间

Calendar cal = Calendar.getInstance();
cal.set(2019,10,11);
Date time = cal.getTime();
System.out.println("当前指定日期是:"+new SimpleDateFormat(fm).format(time));
cal.add(Calendar.DAY_OF_MONTH,-2);
cal.getTime();
System.out.println("前两天的日期是 "+new SimpleDateFormat(fm).format(cal.getTime()));

猜你喜欢

转载自www.cnblogs.com/hbym/p/11730799.html