Java TimeUnit Usage getDiffInMinutes(Calendar startTime, Calendar endTime)

Here you can find the source of getDiffInMinutes(Calendar startTime, Calendar endTime)

Description

Returns the difference of two calendars in minutes

License

Open Source License

Parameter

Parameter Description
startTime a parameter
endTime a parameter

Return

difference of two calendars in minutes

Declaration

public static long getDiffInMinutes(Calendar startTime, Calendar endTime) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

import java.util.concurrent.TimeUnit;

public class Main {
    /**// ww w. ja va2s . c om
     * Returns the difference of two calendars in minutes
     *
     * @param startTime
     * @param endTime
     * @return difference of two calendars in minutes
     */
    public static long getDiffInMinutes(Calendar startTime, Calendar endTime) {
        long diffMillis = Math.abs(endTime.getTimeInMillis() - startTime.getTimeInMillis());
        return TimeUnit.MILLISECONDS.toMinutes(diffMillis);
    }
}

Related

  1. getDayFromTimestamp(final long unixTimestamp)
  2. getDays(final long ms)
  3. getDays(long endTs, Long lookback)
  4. getDeltaBetweenTimestamps(final long start, final long end)
  5. getDifferenceDays(Date d1, Date d2)
  6. getDurationBreakdown(long millis)
  7. getDurationBreakdown(long millis)
  8. getDurationBreakdown(long millis)
  9. getDurationBreakdown(long millis)