Java Day Between getBeteenDays(String begin, String end, String format)

Here you can find the source of getBeteenDays(String begin, String end, String format)

Description

get Beteen Days

License

Open Source License

Declaration

public static Integer getBeteenDays(String begin, String end, String format) throws ParseException 

Method Source Code

//package com.java2s;

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

public class Main {

    public static Integer getBeteenDays(String begin, String end, String format) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(sdf.parse(begin));//from w  ww.j a v  a 2  s. co m
        long time1 = cal.getTimeInMillis();
        cal.setTime(sdf.parse(end));
        long time2 = cal.getTimeInMillis();
        long between_days = (time2 - time1) / (1000 * 3600 * 24);
        return Integer.parseInt(String.valueOf(between_days)) + 1;
    }
}

Related

  1. dayDiff(Date d1, Date d2)
  2. dayDiff(Date start, Date end)
  3. daysDiff(final Date data1, final Date data2)
  4. differentDaysByMillisecond(Date date1, Date date2)
  5. diffInDays(Date date1, Date date2)
  6. getBetweenDays(long longValue1, long longValue2)
  7. getBetweenDays(String start, String end)
  8. getBetweenTwoDayCalender(String startDay, String endDay)
  9. getDateDiff(Date date, int day)