Here you can find the source of getDayNumber(Date startDate, Date endDate)
public static int getDayNumber(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 getDayNumber(Date startDate, Date endDate) { Calendar startCal = Calendar.getInstance(); startCal.setTime(startDate);/*from w w w . j av a2s.c om*/ Calendar endCal = Calendar.getInstance(); endCal.setTime(endDate); if (startCal.after(endCal)) { return 0; } int num = 1; while (startCal.before(endCal)) { startCal.add(Calendar.DATE, 1); num++; } return num; } }