Java Date Compare compareTwoDate(Date beforeDate, Date afterDate)

Here you can find the source of compareTwoDate(Date beforeDate, Date afterDate)

Description

compare Two Date

License

Apache License

Parameter

Parameter Description
beforeDate a parameter
afterDate a parameter

Declaration

public static boolean compareTwoDate(Date beforeDate, Date afterDate) 

Method Source Code

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

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**//from  www .  j  a  v a  2s. co m
     * 
     * @param beforeDate
     * @param afterDate
     * @return
     */
    public static boolean compareTwoDate(Date beforeDate, Date afterDate) {
        if (beforeDate == null && afterDate == null) {
            return false;
        }
        Calendar beforeCalendar = Calendar.getInstance();
        beforeCalendar.setTime(beforeDate);
        Calendar afterCalendar = Calendar.getInstance();
        afterCalendar.setTime(afterDate);
        return (afterCalendar.compareTo(beforeCalendar) > 0);
    }
}

Related

  1. compareTime(Date first, Date second)
  2. compareTimesOfDay(Date time1, Date time2)
  3. compareTo(Date src, Date dest)
  4. compareToCal(Date sDate, Date eDate)
  5. compareToMonthByDate(Date startDate, Date endDate)
  6. compareYear(java.util.Date date1, java.util.Date date2)
  7. compareYMD(Date begindate, Date enddate)
  8. compDate(Date date1, Date date2)
  9. compDate4(Date date1, Date date2)