Here you can find the source of compareTime(Date first, Date second)
Parameter | Description |
---|---|
first | a parameter |
second | a parameter |
public static int compareTime(Date first, Date second)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**/*from w w w . j a v a2 s.com*/ * * @param first * @param second * @return the value 0 if first is equal to second; a value less than 0 if * first is before second; and a value greater than 0 if first is * after second. */ public static int compareTime(Date first, Date second) { Calendar firstCal = new GregorianCalendar(); firstCal.setTime(first); firstCal.set(0, 0, 0); Calendar secondCal = new GregorianCalendar(); secondCal.setTime(second); secondCal.set(0, 0, 0); return firstCal.compareTo(secondCal); } }