Here you can find the source of compareDates(Date date1, Date date2)
Parameter | Description |
---|---|
date1 | the first date to compare |
date2 | the second date to compare with |
public static int compareDates(Date date1, Date date2)
//package com.java2s; /*/* w w w .j a v a 2 s. c om*/ * Jitsi, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ import java.util.*; public class Main { /** * Compares the two dates. The comparison is based only on the day, month * and year values. Returns 0 if the two dates are equals, a value < 0 if * the first date is before the second one and > 0 if the first date is after * the second one. * @param date1 the first date to compare * @param date2 the second date to compare with * @return Returns 0 if the two dates are equals, a value < 0 if * the first date is before the second one and > 0 if the first date is after * the second one */ public static int compareDates(Date date1, Date date2) { return date1.compareTo(date2); } /** * Compares the two dates. The comparison is based only on the day, month * and year values. Returns 0 if the two dates are equals, a value < 0 if * the first date is before the second one and > 0 if the first date is after * the second one. * @param date1 the first date to compare * @param date2 the second date to compare with * @return Returns 0 if the two dates are equals, a value < 0 if * the first date is before the second one and > 0 if the first date is after * the second one */ public static int compareDates(long date1, long date2) { return (date1 < date2 ? -1 : (date1 == date2 ? 0 : 1)); } }