/** *功能:截取两个日期之间的天数
* @param String beginDate,String endDate
* @return int
* @throws ParseException
* */
private static int getDay(String beginDate,String endDate) throws ParseException{
SimpleDateFormat sim = new SimpleDateFormat( "yyyy-MM-dd");
Date d1 = sim.parse(beginDate); Date d2 = sim.parse(endDate); return (int) ((d2.getTime() - d1.getTime()) / (3600L * 1000 * 24));
}
/**
* 描述:一个日期加上一个天数,得到一个新的日期* @param String beginDate, long addDay
* @return Date
* @throws ParseException
* */
private static Date getNewDate(String beginDate, long addDay) throws ParseException {
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
Date d1 = sim.parse(beginDate.trim()); long time = d1.getTime();
addDay = addDay * 24 * 60 * 60 * 1000;
time += addDay;
return new Date(time);
}
/**
* 功能:一个日期时间加上分钟数,得到一个新的日期时间* @param String beginDate, long addDay
* @return Date
* @throws ParseException
* @throws ParseException
* */
private static Date getNewDateTime(String beginDateTime,long addMinutes) throws ParseException{
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date d1 = sim.parse(beginDateTime); long time = d1.getTime();
addMinutes = addMinutes * 60 * 1000;
time += addMinutes;
return new Date(time);
}