Java Date Before daysBefore(Date date1)

Here you can find the source of daysBefore(Date date1)

Description

days Before

License

Apache License

Declaration

public static int daysBefore(Date date1) 

Method Source Code


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

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static int daysBefore(Date date1) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date1);/*from w  ww .jav  a  2  s . co m*/
        long time1 = cal.getTimeInMillis();

        long time2 = System.currentTimeMillis();
        long between_days = (time2 - time1) / (1000 * 3600 * 24);
        return Integer.parseInt(String.valueOf(between_days));

    }
}

Related

  1. before(Date point, Date when)
  2. before(Date sDate, Date eDate)
  3. beforeDay(final Date date1, final Date date2)
  4. beforeDays(Date date, Integer days)
  5. beforeTime(Date time1, Date time2)
  6. getBefore(Date date)
  7. getBeforeDate(final int unit, final int period)
  8. getBeforeDate(String range)
  9. getBeforeHourByCurrentTime(Date now, int mount)