Here you can find the source of subtractSecond(Date startDate, Date endDate)
Parameter | Description |
---|---|
startDate | a parameter |
endDate | a parameter |
public static long subtractSecond(Date startDate, Date endDate)
//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; } }