Here you can find the source of getDateDiff(final Date startDate, final Date endDate)
public static long getDateDiff(final Date startDate, final Date endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static long getDateDiff(final Date startDate, final Date endDate) { if (startDate != null && endDate != null) { final Calendar startCalendar = Calendar.getInstance(); startCalendar.setTime(startDate); final long startDateMiliSeconds = startCalendar.getTimeInMillis(); final Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(endDate); final long endDateMiliSeconds = endCalendar.getTimeInMillis(); final long result = (endDateMiliSeconds - startDateMiliSeconds) / 1000; if (result > 1) { return result; } else { return 0; }/*w ww.ja v a2 s .c o m*/ } else { return 0; } } }