Here you can find the source of compareDateTimeNull(Date d1, Date d2)
public static int compareDateTimeNull(Date d1, Date d2)
//package com.java2s; /*/*from www . j a va 2 s .co m*/ * Copyright (C) 2010 dungnv. All rights reserved. * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.util.Calendar; import java.util.Date; public class Main { public static int compareDateTimeNull(Date d1, Date d2) { if (d1 == null && d2 == null) { return 0; } if (d1 == null) { return -1; } if (d2 == null) { return 1; } int result = 0; Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(d1); cal2.setTime(d2); if (cal1.after(cal2)) { result = 1; } else if (cal1.before(cal2)) { result = -1; } return result; } }