Java Date Compare compareToCal(Date sDate, Date eDate)

Here you can find the source of compareToCal(Date sDate, Date eDate)

Description

compare To Cal

License

Open Source License

Declaration

public static boolean compareToCal(Date sDate, Date eDate) 

Method Source Code

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

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

public class Main {
    public static boolean compareToCal(Date sDate, Date eDate) {

        Calendar sCal = new GregorianCalendar();
        sCal.setTime(sDate);// w ww .  j  a va 2  s . co m
        Calendar eCal = new GregorianCalendar();
        eCal.setTime(eDate);

        return (sCal.getTimeInMillis() == eCal.getTimeInMillis() || before(
                sDate, eDate));
    }

    public static boolean before(Date sDate, Date eDate) {
        Calendar sCal = new GregorianCalendar();
        sCal.setTime(sDate);
        Calendar eCal = new GregorianCalendar();
        eCal.setTime(eDate);
        return sCal.before(eCal);
    }
}

Related

  1. compareStartDateEndDate(String startDate, String endDate)
  2. compareTime(Date date1, Date date2)
  3. compareTime(Date first, Date second)
  4. compareTimesOfDay(Date time1, Date time2)
  5. compareTo(Date src, Date dest)
  6. compareToMonthByDate(Date startDate, Date endDate)
  7. compareTwoDate(Date beforeDate, Date afterDate)
  8. compareYear(java.util.Date date1, java.util.Date date2)
  9. compareYMD(Date begindate, Date enddate)