Here you can find the source of diff(Calendar value1, Calendar value2, int millisInCondition)
public static long diff(Calendar value1, Calendar value2, int millisInCondition)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static long diff(Calendar value1, Calendar value2, int millisInCondition) { long result = 0; long v1 = (value1.getTimeInMillis() + value1 .get(Calendar.ZONE_OFFSET)) / millisInCondition; long v2 = (value2.getTimeInMillis() + value2 .get(Calendar.ZONE_OFFSET)) / millisInCondition; result = v2 - v1;//from w w w .j av a 2 s . c om return result; } }