Java Day Between getBetweenDays(long longValue1, long longValue2)

Here you can find the source of getBetweenDays(long longValue1, long longValue2)

Description

get Between Days

License

Open Source License

Declaration

public static int getBetweenDays(long longValue1, long longValue2) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static int getBetweenDays(long longValue1, long longValue2) {
        long betweenDays = ((longValue1 - longValue2) / 1000) / (60 * 60 * 24);
        return Math.abs((int) betweenDays);
    }//from  w w  w.  j  a v a  2  s. com

    public static int getBetweenDays(String time1, String time2) {
        long betweenDays = 0;
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date date1 = ft.parse(time1);
            Date date2 = ft.parse(time2);
            betweenDays = date1.getTime() - date2.getTime();
            betweenDays = betweenDays / 1000 / 60 / 60 / 24;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return Math.abs((int) betweenDays);
    }
}

Related

  1. dayDiff(Date start, Date end)
  2. daysDiff(final Date data1, final Date data2)
  3. differentDaysByMillisecond(Date date1, Date date2)
  4. diffInDays(Date date1, Date date2)
  5. getBeteenDays(String begin, String end, String format)
  6. getBetweenDays(String start, String end)
  7. getBetweenTwoDayCalender(String startDay, String endDay)
  8. getDateDiff(Date date, int day)
  9. getDateDiff(final Date startDate, final Date endDate)