电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

得到两个日期之间的间隔天数


发布日期:2024/6/23
 

public static int getDaysBetween (String beginDate String endDate) throws ParseException

{

SimpleDateFormat format = new SimpleDateFormat(yyyyMMdd);

Date bDate = formatparse(beginDate);

Date eDate = formatparse(endDate);

Calendar d = new GregorianCalendar();

dsetTime(bDate);

Calendar d = new GregorianCalendar();

dsetTime(eDate);

int days = dget(CalendarDAY_OF_YEAR) dget(CalendarDAY_OF_YEAR);

int y = dget(CalendarYEAR);

if (dget(CalendarYEAR) != y)

{

d = (Calendar) dclone();

do {

days += dgetActualMaximum(CalendarDAY_OF_YEAR);//得到当年的实际天数

dadd(CalendarYEAR );

} while (dget(CalendarYEAR) != y);

}

return days;

}

上一篇:JVM 命令行标志您不知道的5件事

下一篇:方法调用的绑定