Java Day Between differentDaysByMillisecond(Date date1, Date date2)

Here you can find the source of differentDaysByMillisecond(Date date1, Date date2)

Description

different Days By Millisecond

License

Apache License

Declaration

public static int differentDaysByMillisecond(Date date1, Date date2) 

Method Source Code


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

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

import java.util.Date;

public class Main {
    private static SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy-MM-dd");

    public static int differentDaysByMillisecond(Date date1, Date date2) {
        int days = (int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24));
        return days;
    }/*from www . ja v a 2  s . c  o m*/

    public static int differentDaysByMillisecond(String dateStr1, String dateStr2) {
        Date date1 = null;
        Date date2 = null;
        try {
            date1 = dateSdf2.parse(dateStr1);
            date2 = dateSdf2.parse(dateStr2);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        int days = (int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24));
        return days;
    }
}

Related

  1. calculateNumberOfDays(String dateStr)
  2. countDiffDay(String beginDateBase, String endDateBase)
  3. dayDiff(Date d1, Date d2)
  4. dayDiff(Date start, Date end)
  5. daysDiff(final Date data1, final Date data2)
  6. diffInDays(Date date1, Date date2)
  7. getBeteenDays(String begin, String end, String format)
  8. getBetweenDays(long longValue1, long longValue2)
  9. getBetweenDays(String start, String end)