code: public static Date min(Date d1, Date d2)
     {
        Date result;
        if (d1 == null)
        {
           result = d2;
        }
        else
           if (d2 == null)
           {
              result = d1;
           }
           else
           {
              result = (d1.compareTo(d2) < 0) ? d1 : d2;
           }
        return result;
     }
docs: Returns the earlier of two dates, handling null values. A non-null Date
  is always considered to be earlier than a null Date.
  
  @param d1 Date instance
  @param d2 Date instance
  @return Date earliest date