Java Day End subtractSecond(Date startDate, Date endDate)

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

Description

subtract Second

License

Open Source License

Parameter

Parameter Description
startDate a parameter
endDate a parameter

Return

Date

Declaration

public static long subtractSecond(Date startDate, Date endDate) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**/*from  ww w  .  j  a  va2 s.  c  om*/
     * @param startDate
     * @param endDate
     * @return Date
     */
    public static long subtractSecond(Date startDate, Date endDate) {
        Calendar startCalendar = Calendar.getInstance();
        startCalendar.setTime(startDate);
        long startTimeInMillis = startCalendar.getTimeInMillis();
        Calendar endCalendar = Calendar.getInstance();
        endCalendar.setTime(endDate);
        long endTimeInMillis = endCalendar.getTimeInMillis();
        return (endTimeInMillis - startTimeInMillis) / 1000;

    }
}

Related

  1. secondsToEndOfDay(Date aDate)
  2. secondsToEndOfDay(Date aDate)
  3. setEndDay(Date date)
  4. setTimeToEndofDay(Calendar calendar)
  5. setTimeToEndOfDay(Date date)
  6. toDayEnds(Date date)
  7. toDayInterval(Date startDate, Date endDate)
  8. todayOnOrBetween(Date startDate, Date endDate)
  9. yearsBetween(final Date startDate, final Date endDate)