Java Date Subtract subtractNowDay(Date date)

Here you can find the source of subtractNowDay(Date date)

Description

subtract Now Day

License

Open Source License

Declaration

public static long subtractNowDay(Date date) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static long subtractNowDay(Date date) {
        final int aDaymi = 24 * 60 * 60 * 1000;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);//from   ww  w .j a v a  2 s.  c  o  m
        long dateTimeInMillis = calendar.getTimeInMillis();
        Calendar nowCalendar = Calendar.getInstance();
        nowCalendar.setTime(new Date());
        long nowTimeInMillis = nowCalendar.getTimeInMillis();
        return (nowTimeInMillis - dateTimeInMillis) / (aDaymi);
    }
}

Related

  1. subtractDate(Date date, int type, Integer quantity)
  2. subtractDate(Date date, int type, Integer quantity)
  3. subtractDay(final Date date)
  4. subtractDays(Date dt, int days)
  5. subtractDurationToDate(Date date, String duration)
  6. subtractOrAddDayDuration(Date date, int duration)