Here you can find the source of getMinuteDiffByTime(Date time1, Date time2)
public static int getMinuteDiffByTime(Date time1, Date time2)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { private static final long MILLIS_IN_A_SECOND = 1000; private static final long SECONDS_IN_A_MINUTE = 60; public static int getMinuteDiffByTime(Date time1, Date time2) { long startMil = 0; long endMil = 0; Calendar calendar = Calendar.getInstance(); calendar.setTime(time1);/* w w w .j a v a 2 s . c o m*/ calendar.set(1900, 1, 1); startMil = calendar.getTimeInMillis(); calendar.setTime(time2); calendar.set(1900, 1, 1); endMil = calendar.getTimeInMillis(); return (int) ((endMil - startMil) / MILLIS_IN_A_SECOND / SECONDS_IN_A_MINUTE); } }