Here you can find the source of getDateDiff(String startTime, String endTime)
public static long getDateDiff(String startTime, String endTime)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long getDateDiff(String startTime, String endTime) { long diff = 0; DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {//from w ww . j a va 2s . c o m Date d1 = df.parse(startTime); Date d2 = df.parse(endTime); diff = d2.getTime() - d1.getTime(); } catch (Exception e) { } return diff; } }