Java Date to Day getDayNumber(Date startDate, Date endDate)

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

Description

get Day Number

License

Apache License

Declaration

public static int getDayNumber(Date startDate, Date endDate) 

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 getDayNumber(Date startDate, Date endDate) {
        Calendar startCal = Calendar.getInstance();
        startCal.setTime(startDate);/*from w  w w .  j av a2s.c  om*/
        Calendar endCal = Calendar.getInstance();
        endCal.setTime(endDate);
        if (startCal.after(endCal)) {
            return 0;
        }
        int num = 1;
        while (startCal.before(endCal)) {
            startCal.add(Calendar.DATE, 1);
            num++;
        }
        return num;
    }
}

Related

  1. getDayEnd(Date date)
  2. getDayEnd(Date obj)
  3. getDayEnd(final Date date, TimeZone timezone)
  4. getDayFromDate(Date date)
  5. getDayMonthYear(Date aDate, boolean isAddSpace)
  6. getDayOfDate(Date date)
  7. getDayOfThisYear(Date currentdate)
  8. getDayOfYear(Date date)
  9. getDays(Date t, Date baseDate)