日期:2014-05-20 浏览次数:20676 次
Calendar calendar = Calendar.getInstance(); for (int i=0; i<24; i++) { calendar.add(Calendar.MONTH, 1); System.out.printf("%tF\n", calendar.getTime()); }
------解决方案--------------------
/** * * @param months * months sample:10,-10 * @return 当前时间+{months}天的日期 */ public static String DayCalc(Integer months){ SimpleDateFormat dateDf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, months); return dateDf.format(cal.getTime()); }