Java Date Format Check checkDateInToday(Date date)

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

Description

check Date In Today

License

Open Source License

Declaration

public static boolean checkDateInToday(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static boolean checkDateInToday(Date date) {
        if (date == null) {
            return true;
        }/*  w w w . ja  v  a  2 s.  c o  m*/
        boolean flag = false;
        Date now = new Date();

        String nowStr = dateToString(now, "yyyy-MM-dd");
        String dateStr = dateToString(date, "yyyy-MM-dd");

        if (!nowStr.equals(dateStr)) {
            flag = true;
        }

        return flag;
    }

    public static String dateToString(Date date, String formartStr) {
        String strDate = null;

        if ((formartStr != null) && (!"".equals(formartStr))) {
            SimpleDateFormat sdf = new SimpleDateFormat(formartStr);
            strDate = sdf.format(date);
        }
        return strDate;
    }
}

Related

  1. checkDateFormat()
  2. checkDateFormat()
  3. checkDateFormat(String pattern)
  4. checkDateFormat(String strTime, String pattern)
  5. checkDateFormatAndValite(String strDateTime, String format)
  6. checkDateRange(String fromDate, String endDate)
  7. checkDateValidity(String str, String formatString)
  8. checkTime(int id)
  9. checkTimestamp(String timestamp)