Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Date; public class Main { public static long compareMin(Date before, Date after) { if (before == null || after == null) { return 0l; } long dif = 0; if (after.getTime() >= before.getTime()) { dif = after.getTime() - before.getTime(); } else if (after.getTime() < before.getTime()) { dif = after.getTime() + 86400000 - before.getTime(); } dif = Math.abs(dif); return dif / 60000; } }