Java Day of isNowDay(String d)

Here you can find the source of isNowDay(String d)

Description

is Now Day

License

Open Source License

Declaration

public static boolean isNowDay(String d) 

Method Source Code


//package com.java2s;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    public static final String DATE_FORMAT = "yyyy/MM/dd";

    public static boolean isNowDay(String d) {
        boolean flg = false;
        SimpleDateFormat sd = new SimpleDateFormat(DATE_FORMAT);
        String nowDate = sd.format(new Date());
        try {// w  ww  .ja  va2  s.  c o m
            d = sd.format(sd.parse(d));
            if (d.equals(nowDate)) {
                flg = true;
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return flg;
    }

    public static String format(Date d, String format) {
        return format(d, format, Locale.getDefault());
    }

    public static String format(Date d, String format, Locale locale) {
        if (d == null)
            return "";
        DateFormat df = new SimpleDateFormat(format, locale);
        return df.format(d);
    }
}

Related

  1. isDiffIsBiggerThanMin(Date lastLogIn, Date now, Long daysL)
  2. isEndOfDay(GregorianCalendar cal1)
  3. isHoliday(Date date, String[] excludes, String[] includes)
  4. isIn(int reserveDayCount, String dateString)
  5. isInAllDayFormat(String date)
  6. isSomeDay(String date)
  7. lastDays(int count)
  8. long2StringPerDay(long t, SimpleDateFormat sdf)
  9. minDayToLong(String time)