//计算两日期相隔的天数
//first="20080501";
//second="20080515";
public int nDaysBetweenTwoDate(String first, String second) {
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
Date firstDate = null;
Date secondDate = null;
int nDay = 0;
try {
firstDate = df.parse(first);
secondDate = df.parse(second);
nDay = (int) ((secondDate.getTime() - firstDate.getTime()) / (24 * 60 * 60 * 1000));
} catch (Exception e) {
e.printStackTrace();
}
return nDay;
}
阅读(1596) | 评论(0) | 转发(0) |