Here you can find the source of calcDay(String date1, String date2, String format)
public static long calcDay(String date1, String date2, String format) throws Exception
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static long calcDay(String date1, String date2, String format) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat(format); Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(date1));/* ww w .ja va 2s. c o m*/ long time1 = cal.getTimeInMillis(); cal.setTime(sdf.parse(date2)); long time2 = cal.getTimeInMillis(); return (time1 - time2) / (1000 * 3600 * 24); } }