Here you can find the source of day2Day(String startDate, String endDate, String format)
public static long day2Day(String startDate, String endDate, String format) throws Exception
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long day2Day(String startDate, String endDate, String format) throws Exception { if (format == null) format = "yyyy/MM/dd HH:mm:ss.SSS"; SimpleDateFormat sdf = new SimpleDateFormat(format); Date sDate;/* w ww .j a va 2 s .co m*/ Date eDate; long day2day = 0; try { sDate = sdf.parse(startDate); eDate = sdf.parse(endDate); day2day = (eDate.getTime() - sDate.getTime()) / (1000 * 60 * 60 * 24); } catch (Exception e) { throw new Exception("wrong format string"); } return day2day; } }