Java Date Difference getDateDiff(String startTime, String endTime)

Here you can find the source of getDateDiff(String startTime, String endTime)

Description

get Date Diff

License

Apache License

Declaration

public static long getDateDiff(String startTime, String endTime) 

Method Source Code

//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;
    }
}

Related

  1. diffMonth(Date start, Date end)
  2. diffOfDate(String begin, String end)
  3. diffY(Date endDate, Date startDate)
  4. getDateDiff(String startDate, String endDate)
  5. getDateDiff(String startDt, String endDt)
  6. getDateDiffDay(String begindate, String enddate)
  7. getDateDifference(String start, String end)
  8. getDateDifference(String startDateString, String endDateString)
  9. getDateDiffHour(String begindate, String enddate)