Here you can find the source of timeDiff(Calendar date1, Calendar date2)
public static long timeDiff(Calendar date1, Calendar date2)
//package com.java2s; /*//from w w w. j av a2 s. co m * OWN Server is * Copyright (C) 2010-2012 Moreno Cattaneo <moreno.cattaneo@gmail.com> * * This file is part of OWN Server. * * OWN Server is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * OWN Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with OWN Server. If not, see * <http://www.gnu.org/licenses/>. */ import java.util.*; public class Main { public static long timeDiff(Calendar date1, Calendar date2) { long diff = date1.getTimeInMillis() - date2.getTimeInMillis(); return diff; } }