Java Today isToday(Date date)

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

Description

is Today

License

LGPL

Declaration

public static boolean isToday(Date date) 

Method Source Code


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

import java.util.*;

public class Main {
    public static boolean isToday(Date date) {

        Date now = onlyDate(new Date());

        Date d = onlyDate(date);/*from  www.ja  v a  2s  .c om*/

        return now.equals(d);
    }

    public static Date onlyDate(Date date) {

        Calendar cal = Calendar.getInstance();

        cal.setTime(date);

        cal.set(Calendar.MINUTE, 0);

        cal.set(Calendar.HOUR_OF_DAY, 0);

        cal.set(Calendar.SECOND, 0);

        cal.set(Calendar.MILLISECOND, 0);

        return cal.getTime();
    }
}

Related

  1. getYestoday(String sourceDate, String format)
  2. isBeforeToday(Date date)
  3. isBeforeToday(Date date)
  4. isGreaterThanToday(String dateString)
  5. isToday(Date d1)
  6. isToday(Date date)
  7. isToday(Date date, TimeZone timezone)
  8. isToday(Date dateTime)
  9. isToday(final Date date)