Here you can find the source of getDateDiff(String startDt, String endDt)
public static long getDateDiff(String startDt, String endDt)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static long getDateDiff(String startDt, String endDt) { return getDateDiff(startDt, endDt, "yyyy-MM-dd"); }/*from ww w . j a va 2 s. c o m*/ public static long getDateDiff(String startDt, String endDt, String pattern) { SimpleDateFormat sd = new SimpleDateFormat(pattern); long nd = 1000 * 24 * 60 * 60; try { long diff = sd.parse(endDt).getTime() - sd.parse(startDt).getTime(); return diff / nd; } catch (ParseException e) { throw new RuntimeException(e); } } }