Java Utililty Methods Date Before

List of utility methods to do Date Before

Description

The list of methods to do Date Before are organized into topic(s).

Method

booleanisBefore(Date date1, Date date2)
is Before
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
cal1.set(Calendar.HOUR, 0);
cal1.set(Calendar.MINUTE, 0);
cal1.set(Calendar.SECOND, 0);
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal1.set(Calendar.HOUR, 0);
...
booleanisBefore2015(Date date)
is Before
Calendar cal = new GregorianCalendar();
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.YEAR, 2015);
Date fromDate = cal.getTime();
return fromDate.after(date);
booleanisBefore_day(Date time1, Date time2, int days)
time1 < time2 + days
if (time2 == null) {
    return false;
} else if (time1 == null) {
    return true;
boolean result = false;
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(time1);
...
booleanisBeforeCommonEra(Date date)
Returns true if the date is before the common era.
Calendar cal = getCalendarUTC();
cal.setTime(date);
return cal.get(Calendar.ERA) == GregorianCalendar.BC;
booleanisBeforeDate(long time1, long time2)
is Before Date
boolean before = false;
Calendar cal1 = Calendar.getInstance();
cal1.setTimeInMillis(time1);
Calendar cal2 = Calendar.getInstance();
cal2.setTimeInMillis(time2);
before = cal1.get(Calendar.DAY_OF_YEAR) < cal2.get(Calendar.DAY_OF_YEAR);
return before;
booleanisBeforeEndOfDate(Date subject, Date predicate)
Is the subject date before the end of the predicate date?
Calendar cal = new GregorianCalendar();
cal.setTime(zeroTime(predicate));
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.DATE, 1);
return subject.before(cal.getTime());
...
booleanisDataBeforeData2TruncByDay(Date data1, Date data2)
is Data Before Data Trunc By Day
return isDataBeforeData2(getBeginningOfDay(data1), getBeginningOfDay(data2));
booleanisDateBeforeCurrentDate(Date date)
is Date Before Current Date
Calendar cal = Calendar.getInstance();
cal.setTime(date);
Calendar now = Calendar.getInstance();
return cal.before(now);
booleanmonthInRange(Date current, Date before, Date after)
month In Range
Calendar curr = Calendar.getInstance();
curr.setTime(current);
Calendar temp = Calendar.getInstance();
temp.setTime(before);
temp.set(5, 1);
temp.set(11, 0);
temp.set(12, 0);
temp.set(13, 0);
...