Java Milliseconds millisecondsBetween(Date start, Date finish)

Here you can find the source of millisecondsBetween(Date start, Date finish)

Description

Returns the number of milliseconds between the given Dates.

License

Open Source License

Declaration

public static long millisecondsBetween(Date start, Date finish) 

Method Source Code

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

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

public class Main {
    /**//  w  w  w  .j av a 2  s  . c o  m
     * Returns the number of milliseconds between the given Dates.
     */
    public static long millisecondsBetween(Date start, Date finish) {
        Calendar calendar1 = new GregorianCalendar();
        calendar1.setTime(start);
        Calendar calendar2 = new GregorianCalendar();
        calendar2.setTime(finish);
        return calendar2.getTimeInMillis() - calendar1.getTimeInMillis();
    }
}

Related

  1. milliDate(String date)
  2. millisBetween(Date firstDate, Date lastDate)
  3. millisecond(final Date date)
  4. millisecondOf(Date date)
  5. milliseconds(int offset)
  6. millisecondsSinceMidnight(Date date)
  7. millisToDate(String stime)
  8. minutusAndSecondsFromMillis(long millis)
  9. msToString(long milliseconds)