Here you can find the source of getTimeIntervalMins(Date firstDate, Date lastDate)
public static int getTimeIntervalMins(Date firstDate, Date lastDate)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getTimeIntervalMins(Date firstDate, Date lastDate) { if (null == firstDate || null == lastDate) { return -1; }/* w w w. j a v a 2 s . c o m*/ long intervalMilli = lastDate.getTime() - firstDate.getTime(); return (int) (intervalMilli / (60 * 1000)); } public static Date getTime(Date date, int CalendarType, int interval) { Calendar c = Calendar.getInstance(); c.setTime(date); c.add(CalendarType, interval); return c.getTime(); } }