Java Date Difference diffOfDate(String begin, String end)

Here you can find the source of diffOfDate(String begin, String end)

Description

diff Of Date

License

Open Source License

Declaration

public static boolean diffOfDate(String begin, String end) throws Exception 

Method Source Code


//package com.java2s;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static boolean diffOfDate(String begin, String end) throws Exception {
        try {// ww  w . ja va  2  s . c  o m

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
            Date thisdate = formatter.parse(formatter.format(new Date()));

            Date beginDate = formatter.parse(begin);
            Date endDate = formatter.parse(end);

            if ((thisdate.equals(beginDate) || thisdate.after(beginDate))
                    && (thisdate.equals(endDate) || thisdate.before(endDate))) {
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}

Related

  1. differenceOnYear(Date date1, Date date2)
  2. diffIntoMilliSecond(java.util.Date date, java.util.Date date1)
  3. diffMillis(Date d1, Date d2)
  4. diffMonth(Date before, Date after)
  5. diffMonth(Date start, Date end)
  6. diffY(Date endDate, Date startDate)
  7. getDateDiff(String startDate, String endDate)
  8. getDateDiff(String startDt, String endDt)
  9. getDateDiff(String startTime, String endTime)