Java Date to Time getTimeIntervalMins(Date firstDate, Date lastDate)

Here you can find the source of getTimeIntervalMins(Date firstDate, Date lastDate)

Description

get Time Interval Mins

License

Open Source License

Declaration

public static int getTimeIntervalMins(Date firstDate, Date lastDate) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static int getTimeIntervalMins(Date firstDate, Date lastDate) {
        if (null == firstDate || null == lastDate) {
            return -1;
        }/* w  w w. j  a v  a  2 s .  c o  m*/

        long intervalMilli = lastDate.getTime() - firstDate.getTime();
        return (int) (intervalMilli / (60 * 1000));
    }

    public static Date getTime(Date date, int CalendarType, int interval) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(CalendarType, interval);
        return c.getTime();

    }
}

Related

  1. getTimeFromDate(Date date)
  2. getTimeFromDate(final Date date)
  3. getTimeImMillis(Date date)
  4. getTimeInSeconds(Date date)
  5. getTimeInterval(Date fromDate)
  6. getTimeLocalWithoutDst(java.util.Date d)
  7. getTimeLocalWithoutDst(java.util.Date d)
  8. getTimeMargin(String dateTime)
  9. getTimeMax(Date date)