Java Day End toDayInterval(Date startDate, Date endDate)

Here you can find the source of toDayInterval(Date startDate, Date endDate)

Description

to Day Interval

License

Apache License

Declaration

public static long toDayInterval(Date startDate, Date endDate) 

Method Source Code

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

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

public class Main {
    private Calendar calendar;
    private static final String COLON = ":";
    private static final String ZERO = "0";

    public static long toDayInterval(Date startDate, Date endDate) {
        return (endDate.getTime() - startDate.getTime()) / 86400000;
    }//from   ww  w .  jav a  2  s .c  o m

    public static long toDayInterval(GregorianCalendar startDate, GregorianCalendar endDate) {
        return (endDate.getTimeInMillis() - startDate.getTimeInMillis()) / 86400000;

    }

    public String getTime() {
        return getHour() + COLON + getMinute();
    }

    public long getTimeInMillis() {
        return calendar.getTimeInMillis();
    }

    public int getHour() {
        return calendar.get(Calendar.HOUR_OF_DAY);
    }

    public String getMinute() {
        int tempMinute = calendar.get(Calendar.MINUTE);
        return tempMinute < 10 ? ZERO + tempMinute : Integer.toString(tempMinute);
    }
}

Related

  1. setEndDay(Date date)
  2. setTimeToEndofDay(Calendar calendar)
  3. setTimeToEndOfDay(Date date)
  4. subtractSecond(Date startDate, Date endDate)
  5. toDayEnds(Date date)
  6. todayOnOrBetween(Date startDate, Date endDate)
  7. yearsBetween(final Date startDate, final Date endDate)