Here you can find the source of daysBetween(String bdate, String edate)
public static int daysBetween(String bdate, String edate) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static int daysBetween(String bdate, String edate) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(bdate));/*www .j a v a 2s .c o m*/ long time1 = cal.getTimeInMillis(); cal.setTime(sdf.parse(edate)); long time2 = cal.getTimeInMillis(); long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)); } }