Here you can find the source of getBetweenDays(long longValue1, long longValue2)
public static int getBetweenDays(long longValue1, long longValue2)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static int getBetweenDays(long longValue1, long longValue2) { long betweenDays = ((longValue1 - longValue2) / 1000) / (60 * 60 * 24); return Math.abs((int) betweenDays); }//from w w w. j a v a 2 s. com public static int getBetweenDays(String time1, String time2) { long betweenDays = 0; SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd"); try { Date date1 = ft.parse(time1); Date date2 = ft.parse(time2); betweenDays = date1.getTime() - date2.getTime(); betweenDays = betweenDays / 1000 / 60 / 60 / 24; } catch (ParseException e) { e.printStackTrace(); } return Math.abs((int) betweenDays); } }