Java tutorial
//package com.java2s; import java.util.Date; import java.util.concurrent.TimeUnit; public class Main { public static long getDifferenceinMinutes(Date date1, Date date2) { System.out.println(date1.toString()); System.out.println(date2.toString()); if (date1 == null || date2 == null) return 0; long diff = date2.getTime() - date1.getTime(); long diffMinutes = TimeUnit.MINUTES.convert(diff, TimeUnit.MILLISECONDS); return diffMinutes; } }