获取前n天的日期

阅读更多
public static String getNextFewDays(String currentDateString,
			Integer offsetDays) {
		Date tempdate = null;
		try {
			tempdate = new SimpleDateFormat().parse(currentDateString);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		for (int i = 0; i < offsetDays; i++) {
			Calendar cale = Calendar.getInstance();
			cale.setTime(tempdate);
			cale.add(Calendar.DATE, -1);
			tempdate = cale.getTime();
		}

		return new SimpleDateFormat().format(tempdate);
	}

 

你可能感兴趣的:(日期处理)