Here you can find the source of calculateDays(Date startDate, Date endDate)
public static int calculateDays(Date startDate, Date endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int calculateDays(Date startDate, Date endDate) { int presumedDays = 0; Calendar startCal = Calendar.getInstance(); startCal.setTime(startDate);/*from w w w . j av a2 s. c om*/ Calendar endCal = Calendar.getInstance(); endCal.setTime(endDate); if (startCal.getTimeInMillis() == endCal.getTimeInMillis()) { return 0; } while (startCal.before(endDate)) { startCal.add(Calendar.DAY_OF_MONTH, 1); presumedDays++; } return presumedDays; } }