Here you can find the source of dayDiff(Date date1, String date2)
public static long dayDiff(Date date1, String date2)
//package com.java2s; //License from project: Apache License import java.text.*; import java.util.*; public class Main { public static long dayDiff(Date date1, String date2) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); long diff = 0l; try {//from www. jav a 2 s .c o m long d1 = date1.getTime(); long d2 = sdf.parse(date2).getTime(); diff = (Math.abs(d1 - d2) / (1000 * 60)); } catch (ParseException e) { e.printStackTrace(); } return diff; } }