Java TimeUnit Calculate calculateDateDiff(Date date1, Date date2, TimeUnit timeUnit)

Here you can find the source of calculateDateDiff(Date date1, Date date2, TimeUnit timeUnit)

Description

calculate Date Diff

License

Open Source License

Declaration

public static long calculateDateDiff(Date date1, Date date2, TimeUnit timeUnit) 

Method Source Code

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

import java.util.*;
import java.util.concurrent.TimeUnit;

public class Main {
    public static long calculateDateDiff(Date date1, Date date2, TimeUnit timeUnit) {
        long diffInMillies = date2.getTime() - date1.getTime();
        return timeUnit.convert(diffInMillies, TimeUnit.MILLISECONDS);
    }/*  w  w w  .j a v  a 2s .c  om*/
}

Related

  1. abbreviate(final TimeUnit unit)
  2. addTimeUnit(Calendar cal, int unit, int val)
  3. appendTimeout(StringBuilder b, long timeout, TimeUnit unit)
  4. between(final Calendar calendar1, final Calendar calendar2, final TimeUnit scale)
  5. calculateDelatBasedOnRate(int rateLimit, TimeUnit periodUnit, int period, TimeUnit resultingTimeUnit)
  6. calculateTimeout(long timeout, TimeUnit timeUnit)
  7. checkTime(long time, TimeUnit timeunit)
  8. checkTimeUnit(TimeUnit timeUnit)