Here you can find the source of differentDaysByMillisecond(Date date1, Date date2)
public static int differentDaysByMillisecond(Date date1, Date date2)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy-MM-dd"); public static int differentDaysByMillisecond(Date date1, Date date2) { int days = (int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)); return days; }/*from www . ja v a 2 s . c o m*/ public static int differentDaysByMillisecond(String dateStr1, String dateStr2) { Date date1 = null; Date date2 = null; try { date1 = dateSdf2.parse(dateStr1); date2 = dateSdf2.parse(dateStr2); } catch (ParseException e) { e.printStackTrace(); } int days = (int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)); return days; } }