Java Date Between daysBetween(String bdate, String edate)

Here you can find the source of daysBetween(String bdate, String edate)

Description

days Between

License

Open Source License

Declaration

public static int daysBetween(String bdate, String edate) throws ParseException 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {

    public static int daysBetween(String bdate, String edate) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(sdf.parse(bdate));/*www  .j a v  a 2s  .c o m*/
        long time1 = cal.getTimeInMillis();
        cal.setTime(sdf.parse(edate));
        long time2 = cal.getTimeInMillis();
        long between_days = (time2 - time1) / (1000 * 3600 * 24);
        return Integer.parseInt(String.valueOf(between_days));
    }
}

Related

  1. daysBetween(Date smdate, Date bdate)
  2. daysBetween(Date smdate, Date bdate)
  3. daysBetween(Date startDate, Date endDate)
  4. daysBetween(final Date date1, final Date date2)
  5. daysBetween(final Date dateA, final Date dateB)
  6. daysBetween(String beginDate, String endDate)
  7. daysBetween(String from, String to)
  8. daysBetween(String from, String to, String form)
  9. daysBetween(String from, String to, String format)