Java Day Between getTimeDifference(Date date1, Date date2)

Here you can find the source of getTimeDifference(Date date1, Date date2)

Description

get Time Difference

License

Apache License

Declaration

public static long getTimeDifference(Date date1, Date date2) 

Method Source Code

//package com.java2s;
// Licensed to the Apache Software Foundation (ASF) under one

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static long getTimeDifference(Date date1, Date date2) {

        Calendar dateCalendar1 = Calendar.getInstance();
        dateCalendar1.setTime(date1);//from w  w w  . j  a v  a 2  s.  c o m
        Calendar dateCalendar2 = Calendar.getInstance();
        dateCalendar2.setTime(date2);

        return (dateCalendar1.getTimeInMillis() - dateCalendar2
                .getTimeInMillis()) / 1000;

    }
}

Related

  1. getMinutesDifference(final Date begin, final Date end)
  2. getMonthDifference(Date from, Date to)
  3. getMonthsDifference(Date earlierDate, Date laterDate)
  4. getNumDaysDiffExclTime(Date date1, Date date2)
  5. getTimeDifference(Date d1, Date d2)
  6. getTimeDifference(Date otherDate)
  7. getTodayDiff(String diffDate)
  8. getWorkingDaysBetween(Date fromDate, Date toDate)
  9. getYearDiff(Date date1, Date date2)