Java Day Between getMinuteDiffByTime(Date time1, Date time2)

Here you can find the source of getMinuteDiffByTime(Date time1, Date time2)

Description

get Minute Diff By Time

License

Open Source License

Declaration

public static int getMinuteDiffByTime(Date time1, Date time2) 

Method Source Code

//package com.java2s;

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

public class Main {
    private static final long MILLIS_IN_A_SECOND = 1000;
    private static final long SECONDS_IN_A_MINUTE = 60;

    public static int getMinuteDiffByTime(Date time1, Date time2) {
        long startMil = 0;
        long endMil = 0;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(time1);/*  w  w w .j  a  v  a 2 s  . c o m*/
        calendar.set(1900, 1, 1);
        startMil = calendar.getTimeInMillis();
        calendar.setTime(time2);
        calendar.set(1900, 1, 1);
        endMil = calendar.getTimeInMillis();
        return (int) ((endMil - startMil) / MILLIS_IN_A_SECOND / SECONDS_IN_A_MINUTE);
    }
}

Related

  1. getDifferenceInDays(final Date startDate, final Date endDate)
  2. getDifferenceOfDays(String dateFromStr, String dateToStr, String dateFormat)
  3. getDifferencesBetweenIndicateDays( final Date minorDate, final Date majorDate)
  4. getDiffMilliSeconds(Date form, Date to)
  5. getManyWeeksDifference(Date a, Date b)
  6. getMinutesDifference(final Date begin, final Date end)
  7. getMonthDifference(Date from, Date to)
  8. getMonthsDifference(Date earlierDate, Date laterDate)
  9. getNumDaysDiffExclTime(Date date1, Date date2)