Java Date Difference diffY(Date endDate, Date startDate)

Here you can find the source of diffY(Date endDate, Date startDate)

Description

diff Y

License

Apache License

Declaration

public static boolean diffY(Date endDate, Date startDate) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String DATE_FORMAT_2 = "yyyy-MM-dd";

    public static boolean diffY(Date endDate, Date startDate) {
        String endTime = toStringFormat_2(endDate);
        String startTime = toStringFormat_2(startDate);

        return endTime.compareTo(startTime) >= 1 ? true : false;
    }/*from   w ww. j  av  a2  s .  co m*/

    /**
     * toString for format 2
     * 
     * @param date
     * @return
     */
    public static String toStringFormat_2(Date date) {

        return dateToString(date, DATE_FORMAT_2);
    }

    public static String dateToString(Date date, String format) {
        if (null == date) {
            return "";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}

Related

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