`

获取前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);
	}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics