Here you can find the source of getBetweenDays(String strFromDate, String strToDate)
public static int getBetweenDays(String strFromDate, String strToDate)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static int getBetweenDays(String strFromDate, String strToDate) { try {// w w w.ja v a2s. co m Calendar clFrom = new GregorianCalendar(); int iYear = Integer.parseInt(strFromDate.substring(0, 4)); int iMonth = Integer.parseInt(strFromDate.substring(4, 6)); int iDay = Integer.parseInt(strFromDate.substring(6, 8)); clFrom.set(iYear, iMonth, iDay, 0, 0, 0); Calendar clTo = new GregorianCalendar(); iYear = Integer.parseInt(strToDate.substring(0, 4)); iMonth = Integer.parseInt(strToDate.substring(4, 6)); iDay = Integer.parseInt(strToDate.substring(6, 8)); clTo.set(iYear, iMonth, iDay, 0, 0, 0); long llTmp = clTo.getTime().getTime() - clFrom.getTime().getTime(); return new Long(llTmp / 1000 / 3600 / 24).intValue(); } catch (Exception e) { return Integer.MIN_VALUE; } } }