Java Date to Day getDayCount(java.util.Date _startDate, java.util.Date _endDate)

Here you can find the source of getDayCount(java.util.Date _startDate, java.util.Date _endDate)

Description

get Day Count

License

Open Source License

Declaration

public static int getDayCount(java.util.Date _startDate, java.util.Date _endDate) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {

    public static int getDayCount(java.util.Date _startDate, java.util.Date _endDate) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(_startDate);// w w w  .ja  v  a 2  s .c om
        int startDay = calendar.get(Calendar.DAY_OF_YEAR);
        int startYear = calendar.get(Calendar.YEAR);
        calendar.clear();
        calendar.setTime(_endDate);
        int endDay = calendar.get(Calendar.DAY_OF_YEAR);
        int endYear = calendar.get(Calendar.YEAR);
        calendar.clear();
        return (endYear - startYear) * 365 + (endDay - startDay);
    }
}

Related

  1. getDay(Date date, int day)
  2. getDay(Date dateParam)
  3. getDay(java.util.Date date)
  4. getDay(String strDate)
  5. getDayBetween(Date startDate, Date endDate)
  6. getDayEnd(Date date)
  7. getDayEnd(Date date)
  8. getDayEnd(Date date)
  9. getDayEnd(Date obj)