Java tutorial
//package com.java2s; import java.util.Date; import java.util.Date; public class Main { public static long diffOfDate2(Date begin, Date end) { if (begin == null || end == null) return 0; long diff = end.getTime() - begin.getTime(); long diffDays = diff / (24 * 60 * 60 * 1000); return diffDays; } }