List of utility methods to do Date Compare
boolean | getCompareResult(String date1, String date2) get Compare Result Calendar calendar1 = Calendar.getInstance(); calendar1.setTime(strToDate(date1)); Calendar calendar2 = Calendar.getInstance(); calendar2.setTime(strToDate(date2)); if (calendar2.after(calendar1)) { return true; return false; ... |
boolean | isAfterOrEqual(Date date, Date toCompare) Returns true if toCompare is after or on same day as date. if (date == null || toCompare == null) { return false; date = zeroTime(date); toCompare = zeroTime(toCompare); return toCompare.compareTo(date) <= 0; |
boolean | isBeforeDate(String sCompareDate) is Before Date SimpleDateFormat clsFormat = new SimpleDateFormat("yyyy-MM-dd"); try { Date compareDate = clsFormat.parse(sCompareDate); Date currentDate = clsFormat.parse(clsFormat.format(new Date())); if (currentDate.before(compareDate)) { return true; } catch (ParseException e) { ... |
boolean | isInDate(Date date, Date compareDate) is In Date if (compareDate.after(getStartDate(date)) && compareDate.before(getFinallyDate(date))) { return true; } else { return false; |
Date | max(Collection max Collection<Date> nemNullDatumok = new ArrayList<Date>(); for (Date date : datumok) { if (date != null) { nemNullDatumok.add(date); Date max = nemNullDatumok.isEmpty() ? null : Collections.max(nemNullDatumok); return max; ... |
Date | max(Date a, Date b) max if (a.after(b)) { return a; return b; |
Date | max(final Date a, final Date b) max if (a == null) { return b; } else if (b == null) { return a; return a.after(b) ? a : b; |
Date | max(Set max return (Date) new ArrayList(dateSet).stream().max(new Comparator<Date>() { @Override public int compare(Date o1, Date o2) { return o1.compareTo(o2); }).get(); |
List | mergeNonDateKeys(List merge Non Date Keys if (rowKeys.size() > 0) { List<String> result = new ArrayList<String>(rowKeys.size() + columnKeys.size()); result.addAll(rowKeys); result.addAll(columnKeys); return result; } else { return columnKeys; |
Calendar | min(Calendar... dates) Takes in a varargs of calendars and returns the one with the earliest date Calendar least = null; for (Calendar calendar : dates) { if (calendar != null) { if (least == null) { least = calendar; } else { if (calendar.before(least)) { least = calendar; ... |