Java TimeUnit Usage getBookingDays(Calendar start, Calendar end)

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

Description

Returns the entire number of business booking days between two given dates

License

Open Source License

Parameter

Parameter Description
start pickup date (included)
end return date (included)

Return

the number of booking days

Declaration

public static long getBookingDays(Calendar start, Calendar end) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

import java.util.concurrent.TimeUnit;

public class Main {
    /**// w ww  . j ava  2 s. co  m
     * Returns the entire number of business booking days between two given dates
     *
     * @param start pickup date (included)
     * @param end return date (included)
     * @return the number of booking days
     */
    public static long getBookingDays(Calendar start, Calendar end) {
        long diff = end.getTime().getTime() - start.getTime().getTime();
        return TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS) + 1;
    }
}

Related

  1. generateRandomDateTimeForLogEvent(Date laterThan)
  2. getAge(Date birthday)
  3. getAge(long currentTimeMillis, long headerTimestampSec)
  4. getAllCombinations( ArrayList lengths)
  5. getAllDaysCount(final long milliseconds)
  6. getCurrentDateTime(int offsetMin)
  7. getCurrentTimeMillis()
  8. getCurrentTimestamp()
  9. getCurrentTimestampInSeconds()