Android Date Interval Get getDiff(String startTime, String endTime)

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

Description

get Diff

License

Apache License

Declaration

public static long getDiff(String startTime, String endTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static long getDiff(String startTime, String endTime) {
        long diff = 0;
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {/*from  w  ww  . j  a va2  s.c o m*/
            Date startDate = ft.parse(startTime);
            Date endDate = ft.parse(endTime);
            diff = startDate.getTime() - endDate.getTime();
            diff = diff / 1000;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return diff;
    }
}

Related

  1. dateDiff(String startTime, String endTime, String format, String str)
  2. dayDiff(Date date1, Date date2)
  3. dayOffset(Date date, int offset)
  4. daysBetweenDate(Date date1, Date date2)
  5. getDiff(String startTime, String endTime)
  6. getDiffDays(String startDate, String endDate)
  7. getDiffDays(String startDate, String endDate)
  8. getDiffHour(String startTime, String endTime)
  9. getDiffHour(String startTime, String endTime)