Java Calendar Between hoursBetween(Calendar startDate, Calendar endDate)

Here you can find the source of hoursBetween(Calendar startDate, Calendar endDate)

Description

hours Between

License

Apache License

Declaration

public static long hoursBetween(Calendar startDate, Calendar endDate) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

public class Main {
    public static long hoursBetween(Calendar startDate, Calendar endDate) {
        Calendar date = (Calendar) startDate.clone();
        long hoursBetween = -1;
        while (date.before(endDate) || date.equals(endDate)) {
            date.add(Calendar.HOUR, 1);
            hoursBetween++;/*from  ww w  .j  av a 2  s . c om*/
        }
        return hoursBetween;
    }
}

Related

  1. getDaysBetween(Calendar start, Calendar end)
  2. getDaysBetween(Calendar startDate, Calendar endDate)
  3. getDaysBetween(final Calendar start, final Calendar end)
  4. getFmtCalendar(Calendar c, long betweenTimeout, StringBuilder sb)
  5. hoursBetween(Calendar start, Calendar end, boolean assumeSameDate)
  6. isBetween(Calendar time, Calendar start, Calendar end)
  7. numberOfDaysBetween(Calendar start, Calendar end)