Java Hour getHour(Date begin, Date end)

Here you can find the source of getHour(Date begin, Date end)

Description

get Hour

License

Apache License

Declaration

public static int getHour(Date begin, Date end) 

Method Source Code

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

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

public class Main {

    public static int getHour(Date begin, Date end) {
        Calendar c1 = Calendar.getInstance();
        c1.setTime(begin);// www  .j  av  a2  s.  c  om
        Calendar c2 = Calendar.getInstance();
        c2.setTime(end);
        Long millisecond = c2.getTimeInMillis() - c1.getTimeInMillis();
        Long hour = millisecond / 1000 / 60 / 60;
        Long minute = (millisecond / 1000 / 60) % 60;
        if (minute >= 30) {
            hour++;
        }

        return hour.intValue();
    }
}

Related

  1. getHour()
  2. getHour()
  3. getHour()
  4. getHour()
  5. getHour(boolean military)
  6. getHour(Date d)
  7. getHour(Date d)
  8. getHour(Date d)
  9. getHour(Date date)