Here you can find the source of toDayInterval(Date startDate, Date endDate)
public static long toDayInterval(Date startDate, Date endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { private Calendar calendar; private static final String COLON = ":"; private static final String ZERO = "0"; public static long toDayInterval(Date startDate, Date endDate) { return (endDate.getTime() - startDate.getTime()) / 86400000; }//from ww w . jav a 2 s .c o m public static long toDayInterval(GregorianCalendar startDate, GregorianCalendar endDate) { return (endDate.getTimeInMillis() - startDate.getTimeInMillis()) / 86400000; } public String getTime() { return getHour() + COLON + getMinute(); } public long getTimeInMillis() { return calendar.getTimeInMillis(); } public int getHour() { return calendar.get(Calendar.HOUR_OF_DAY); } public String getMinute() { int tempMinute = calendar.get(Calendar.MINUTE); return tempMinute < 10 ? ZERO + tempMinute : Integer.toString(tempMinute); } }