Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static long getTimeDiff(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) return 0; return cal2.getTimeInMillis() - cal1.getTimeInMillis(); } }