Java Day End getBetweenDays(String strFromDate, String strToDate)

Here you can find the source of getBetweenDays(String strFromDate, String strToDate)

Description

get Between Days

License

Apache License

Declaration

public static int getBetweenDays(String strFromDate, String strToDate) 

Method Source Code

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

import java.util.*;

public class Main {

    public static int getBetweenDays(String strFromDate, String strToDate) {
        try {//  w  w w.ja  v  a2s. co  m
            Calendar clFrom = new GregorianCalendar();
            int iYear = Integer.parseInt(strFromDate.substring(0, 4));
            int iMonth = Integer.parseInt(strFromDate.substring(4, 6));
            int iDay = Integer.parseInt(strFromDate.substring(6, 8));
            clFrom.set(iYear, iMonth, iDay, 0, 0, 0);
            Calendar clTo = new GregorianCalendar();
            iYear = Integer.parseInt(strToDate.substring(0, 4));
            iMonth = Integer.parseInt(strToDate.substring(4, 6));
            iDay = Integer.parseInt(strToDate.substring(6, 8));
            clTo.set(iYear, iMonth, iDay, 0, 0, 0);
            long llTmp = clTo.getTime().getTime() - clFrom.getTime().getTime();
            return new Long(llTmp / 1000 / 3600 / 24).intValue();
        } catch (Exception e) {
            return Integer.MIN_VALUE;
        }
    }
}

Related

  1. endOfTheMonth(java.util.Date date, Locale locale)
  2. endOfYear(Date referenceDate, TimeZone timeZone)
  3. fillBetweenDays(Date from, Date to)
  4. getAgeInDays(Date startDate, Date endDate)
  5. getApartDate(Date startDate, Date endDate)
  6. getCalender(Date date)
  7. getCertificateEndDate(int days)
  8. getDatebetweenOfDays(Date startDate, Date endDate)
  9. getDateEnd(java.util.Date d)