Java Date to Time getTimeInSeconds(Date date)

Here you can find the source of getTimeInSeconds(Date date)

Description

Gets time in seconds.

License

Open Source License

Parameter

Parameter Description
date the date

Return

time in seconds

Declaration

public static int getTimeInSeconds(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*from ww  w  .j a  v a 2 s  .  com*/
     * Gets time in seconds. E.g. 600 for 00:10.
     * @param date the date
     * @return time in seconds
     */
    public static int getTimeInSeconds(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.HOUR_OF_DAY) * 60 * 60 + calendar.get(Calendar.MINUTE) * 60
                + calendar.get(Calendar.SECOND);
    }
}

Related

  1. getTimeDateStr(Date date)
  2. getTimeDeltaValue(Date t, Date baseDate, String tDelta)
  3. getTimeFromDate(Date date)
  4. getTimeFromDate(final Date date)
  5. getTimeImMillis(Date date)
  6. getTimeInterval(Date fromDate)
  7. getTimeIntervalMins(Date firstDate, Date lastDate)
  8. getTimeLocalWithoutDst(java.util.Date d)
  9. getTimeLocalWithoutDst(java.util.Date d)