Java Today isToday(Date dateTime)

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

Description

is Today

License

Open Source License

Declaration

public static boolean isToday(Date dateTime) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static boolean isToday(Date dateTime) {
        Calendar someCa = GregorianCalendar.getInstance();
        someCa.setTime(dateTime);/*from  w ww . j a v  a 2s .  c  o m*/

        int syear = someCa.get(Calendar.YEAR);
        int smonth = someCa.get(Calendar.MONTH);
        int sday = someCa.get(Calendar.DAY_OF_YEAR);

        Calendar currentCa = GregorianCalendar.getInstance();

        int cyear = currentCa.get(Calendar.YEAR);
        int cmonth = currentCa.get(Calendar.MONTH);
        int cday = currentCa.get(Calendar.DAY_OF_YEAR);
        if (syear == cyear && smonth == cmonth && sday == cday) {
            return true;
        }
        return false;
    }
}

Related

  1. isGreaterThanToday(String dateString)
  2. isToday(Date d1)
  3. isToday(Date date)
  4. isToday(Date date)
  5. isToday(Date date, TimeZone timezone)
  6. isToday(final Date date)
  7. isToday(final Date date)
  8. isToday(final Date date)
  9. isToday(int dateInt)