Java Second Compare getSecondBetweenDate(Date d1, Date d2)

Here you can find the source of getSecondBetweenDate(Date d1, Date d2)

Description

get Second Between Date

License

Apache License

Declaration

public static Integer getSecondBetweenDate(Date d1, Date d2) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");

    public static Integer getSecondBetweenDate(Date d1, Date d2) {
        Long second = (d2.getTime() - d1.getTime()) / 1000;
        return second.intValue();
    }/*from  ww  w  .jav  a2  s .c  om*/

    public static String getTime(String pattern) {
        return new SimpleDateFormat(pattern).format(new Date());
    }
}

Related

  1. compareDate(Date firstDate, Date secondDate)
  2. compareIgnoreSecond(Date date, Date anotherDate)
  3. getSecondCa(Date d1, Date d2)
  4. getSecondsOfTowDiffDate(String p_startDate, String p_endDate)
  5. secondBetween(String date)
  6. secondOfDate(Date d1, Date d2)