Java Calendar Minute getMinutesInterval(Calendar start, Calendar end)

Here you can find the source of getMinutesInterval(Calendar start, Calendar end)

Description

get Minutes Interval

License

Open Source License

Declaration

public static int getMinutesInterval(Calendar start, Calendar end) 

Method Source Code

//package com.java2s;
/**/*  w  w w.j a v a  2s  .  c om*/
 * This file is part of JEMMA - http://jemma.energy-home.org
 * (C) Copyright 2013 Telecom Italia (http://www.telecomitalia.it)
 *
 * JEMMA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License (LGPL) version 3
 * or later as published by the Free Software Foundation, which accompanies
 * this distribution and is available at http://www.gnu.org/licenses/lgpl.html
 *
 * JEMMA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License (LGPL) for more details.
 *
 */

import java.util.Calendar;

public class Main {
    public static int getMinutesInterval(Calendar start, Calendar end) {
        if (start.after(end))
            throw new IllegalArgumentException("Start time must preceede End time.");

        int minutes = end.get(Calendar.MINUTE) - start.get(Calendar.MINUTE);
        minutes += 60 * (end.get(Calendar.HOUR_OF_DAY) - start.get(Calendar.HOUR_OF_DAY));
        minutes += 24 * 60 * Math.abs(end.get(Calendar.DAY_OF_WEEK) - start.get(Calendar.DAY_OF_WEEK));
        return minutes;
    }
}

Related

  1. getFirstMinuteOfDay(Calendar dt)
  2. getMinute(Calendar cal)
  3. getMinutes(Calendar cal)
  4. getMinutes(Calendar cal1, Calendar cal2)
  5. getMinutes(String expression, Calendar time)
  6. getOffsetInMinutes(Calendar cal)
  7. isNow(Calendar cal, Locale locale, boolean minuteCheck)
  8. minuteFloor(Calendar calendar)
  9. roundByMinutes(Calendar cal, int interval)