Java tutorial
//package com.java2s; import java.util.Date; public class Main { private static final long MS_PER_DAY = 86400000; /** * Returns the number of days since 01/01/1970. The value is rounded off to * the floor value and does not take daylight saving time into account. * * @param date the date. * @return number of days since Epoch. */ public static long getDays(Date date) { return date.getTime() / MS_PER_DAY; } /** * Returns the number of days between the start date (inclusive) and end * date (exclusive). The value is rounded off to the floor value and does * not take daylight saving time into account. * * @param startDate the start-date. * @param endDate the end-date. * @return the number of days between the start and end-date. */ public static long getDays(Date startDate, Date endDate) { return (endDate.getTime() - startDate.getTime()) / MS_PER_DAY; } }