Here you can find the source of dateDiff(Date d1, Date d2)
Parameter | Description |
---|---|
d1 | The lowest date on the range |
d2 | The highest date on the range |
public static Long dateDiff(Date d1, Date d2)
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.util.concurrent.TimeUnit; public class Main { /**/*from w w w.ja va 2s. com*/ * Returns the number of days between d1 and d2. * * @param d1 * The lowest date on the range * @param d2 * The highest date on the range * @return The number of days between d1 and d2 */ public static Long dateDiff(Date d1, Date d2) { long diff = d2.getTime() - d1.getTime(); return TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS); } }