public static Date rollMinute(Date d, int minute) { return new Date(d.getTime() + minute * 60 * 1000); } public static Date rollDay(Date d, int day) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.DAY_OF_MONTH, day); return cal.getTime(); } public static Date rollMon(Date d, int mon) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.MONTH, mon); return cal.getTime(); } public static Date rollYear(Date d, int year) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.YEAR, year); return cal.getTime(); } public static Date rollDate(Date d, int year, int mon, int day) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.YEAR, year); cal.add(Calendar.MONTH, mon); cal.add(Calendar.DAY_OF_MONTH, day); return cal.getTime(); }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)