List of usage examples for org.apache.commons.lang3.time DateUtils truncatedCompareTo
public static int truncatedCompareTo(final Date date1, final Date date2, final int field)
From source file:cat.albirar.framework.utilities.DatesUtilities.java
/** * Compare two date+time, with care of null. The information bellow second part of time are ignored. A null value is * considered less than any non-null value. * // ww w.j a va2s .c o m * @param d1 The first date+time * @param d2 The second date+time * @return Zero if both are equals (even if both are nulls), a number less than zero if d1 is minor than d2 and a * number greater than zero if d1 is greater than d2. * @see DateUtils#truncatedCompareTo(Calendar, Calendar, int) */ public static final int nullSafeCompareDateTime(Date d1, Date d2) { if (d1 == null || d2 == null) { if (d1 == d2) { return 0; } if (d1 == null) { return -1; } return 1; } return DateUtils.truncatedCompareTo(d1, d2, Calendar.SECOND); }
From source file:cat.albirar.framework.utilities.DatesUtilities.java
/** * Compare two dates, with care of null. The time part of both dates are ignored (from hour and bellow) * /*from w ww . j a v a 2s . com*/ * @param d1 The first date * @param d2 The second date * @return Zero if both are equals (even if both are nulls), a number less than zero if d1 is minor than d2 and a * number greater than zero if d1 is greater than d2. * @see DateUtils#truncatedCompareTo(Calendar, Calendar, int) */ public static final int nullSafeCompareDate(Date d1, Date d2) { if (d1 == null || d2 == null) { if (d1 == d2) { return 0; } if (d1 == null) { return -1; } return 1; } return DateUtils.truncatedCompareTo(d1, d2, Calendar.DATE); }