Java Date After isAfterToday(Date dag)

Here you can find the source of isAfterToday(Date dag)

Description

is After Today

License

Apache License

Declaration

public static boolean isAfterToday(Date dag) 

Method Source Code

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

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

public class Main {
    public static boolean isAfterToday(Date dag) {
        return getStartOfDay(dag) > getEndOfDay(new Date());
    }//from   w  ww  .  ja v a2  s. c  om

    public static long getStartOfDay(Date day) {
        Calendar startOfDay = Calendar.getInstance();
        startOfDay.setTime(day);

        startOfDay.set(Calendar.HOUR_OF_DAY, 0);
        startOfDay.set(Calendar.MINUTE, 0);
        startOfDay.set(Calendar.SECOND, 0);
        startOfDay.set(Calendar.MILLISECOND, 0);

        return startOfDay.getTimeInMillis();
    }

    public static long getEndOfDay(Date day) {
        Calendar endOfDay = Calendar.getInstance();
        endOfDay.setTime(day);

        endOfDay.set(Calendar.HOUR_OF_DAY, 23);
        endOfDay.set(Calendar.MINUTE, 59);
        endOfDay.set(Calendar.SECOND, 59);
        endOfDay.set(Calendar.MILLISECOND, 0);

        return endOfDay.getTimeInMillis();
    }
}

Related

  1. getSpecifiedDayAfter4Date(Date date)
  2. isAfter(Date d1, Date d2)
  3. isAfter(Date date1, Date date2)
  4. isAfterForDay(Date date, Date ref)
  5. isAfterHour(Date source, int hour)
  6. isDateAfter(Date date1, Date date2)
  7. isEqualOrAfterTomorrow(Date d)
  8. isInSameDayOrAfter(Date d1, Date d2)
  9. isNotAfter(Date sDate, Date eDate)