Here you can find the source of calculateDateDiff(Date date1, Date date2, TimeUnit timeUnit)
public static long calculateDateDiff(Date date1, Date date2, TimeUnit timeUnit)
//package com.java2s; //License from project: Open Source License import java.util.*; import java.util.concurrent.TimeUnit; public class Main { public static long calculateDateDiff(Date date1, Date date2, TimeUnit timeUnit) { long diffInMillies = date2.getTime() - date1.getTime(); return timeUnit.convert(diffInMillies, TimeUnit.MILLISECONDS); }/* w w w .j a v a 2s .c om*/ }