Java Day Between timeDifferenceInSeconds(Date startDate, Date endDate)

Here you can find the source of timeDifferenceInSeconds(Date startDate, Date endDate)

Description

time Difference In Seconds

License

Apache License

Declaration

public static Long timeDifferenceInSeconds(Date startDate, Date endDate) 

Method Source Code

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

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

public class Main {
    private Calendar calendar;
    private static final String COLON = ":";
    private static final String ZERO = "0";

    public static Long timeDifferenceInSeconds(Date startDate, Date endDate) {
        if (startDate == null || endDate == null) {
            return null;
        }//from  w  w w . j  a  v a 2s  . c  o  m
        return (endDate.getTime() - startDate.getTime()) / (1000L);
    }

    public String getTime() {
        return getHour() + COLON + getMinute();
    }

    public int getHour() {
        return calendar.get(Calendar.HOUR_OF_DAY);
    }

    public String getMinute() {
        int tempMinute = calendar.get(Calendar.MINUTE);
        return tempMinute < 10 ? ZERO + tempMinute : Integer.toString(tempMinute);
    }
}

Related

  1. monthDiff(Date fromDate, Date toDate)
  2. monthDifference(final Date a, final Date b)
  3. monthsDiff(final Date data1, final Date data2)
  4. stdNewDate(String tzDiff)
  5. substractDate(final Date date, final Integer different)
  6. timeDifferenceWithCurrentTime(Date startTime)
  7. truncateDifferMonths(Date date)
  8. yearDifference(Date date1, Date date2)
  9. yearTimeDiff(Date d1, Date d2)