Return-Path: Delivered-To: apmail-incubator-ofbiz-user-archive@locus.apache.org Received: (qmail 782 invoked from network); 6 Oct 2006 17:21:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Oct 2006 17:21:17 -0000 Received: (qmail 53430 invoked by uid 500); 6 Oct 2006 17:21:15 -0000 Delivered-To: apmail-incubator-ofbiz-user-archive@incubator.apache.org Received: (qmail 53410 invoked by uid 500); 6 Oct 2006 17:21:15 -0000 Mailing-List: contact ofbiz-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ofbiz-user@incubator.apache.org Delivered-To: mailing list ofbiz-user@incubator.apache.org Received: (qmail 53401 invoked by uid 99); 6 Oct 2006 17:21:15 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Oct 2006 10:21:15 -0700 Authentication-Results: idunn.apache.osuosl.org header.from=pbwebguy@gmail.com; domainkeys=good X-ASF-Spam-Status: No, hits=0.5 required=5.0 tests=DNS_FROM_RFC_ABUSE DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 Received: from [64.233.162.201] ([64.233.162.201:62107] helo=nz-out-0102.google.com) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 04/F6-24193-68096254 for ; Fri, 06 Oct 2006 10:21:12 -0700 Received: by nz-out-0102.google.com with SMTP id v1so338176nzb for ; Fri, 06 Oct 2006 10:21:08 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Sa7bMwo0AjqLYByvw1u/RTj/wOQ2Ymmp99HNmjnvuIiVIw7HzGL7NTuC1uSk8gbhOA19cmHaMjn1uQZFqZpyNZIqwH1+orsmQoeNk/s2CtrN7lzBonmAScH/H2RcO2TLeaQ9Z95BYV/+GGJ/S+kZKIMGeaGnxwHKqzTRFuijX7o= Received: by 10.65.59.20 with SMTP id m20mr5088027qbk; Fri, 06 Oct 2006 10:14:48 -0700 (PDT) Received: by 10.64.220.8 with HTTP; Fri, 6 Oct 2006 10:14:48 -0700 (PDT) Message-ID: <3a57849a0610061014p4aaefcc4p5bf6b74feb0c864@mail.gmail.com> Date: Fri, 6 Oct 2006 13:14:48 -0400 From: "John Martin" To: ofbiz-user@incubator.apache.org Subject: Re: Date Comparison Function In-Reply-To: <20061006162402.45693.qmail@web80614.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45265A5B.8090106@sastau.it> <20061006162402.45693.qmail@web80614.mail.yahoo.com> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N The problem with that is that comparing datetime means that 10/06/2006 12:00:01 != 10/06/2006 18:30:00. I just want to see if a Date is the same, before, or after another. The time messes up the tests. I think using the commons/validator is the right thing to do since the less code we write, the less we have to maintain. On the otherhand, my method is short and sweet. /** * compares two dates (excluding time) to determine if date A is equal, before or after date B * @param dateA a java.util.Date object * @param dateB a java.util.Date object * @return int a value of zero (0) indicates the dates are equal; a value less than zero (< 0) date A is prior to B; and a * value greater than zero (> 0) indicates date A occurs after B */ public static int compareDates(java.util.Date dateA, java.util.Date dateB) { String strDateA = UtilDateTime.toDateString(dateA, "yyyyMMdd"); String strDateB = UtilDateTime.toDateString(dateB, "yyyyMMdd"); return strDateA.compareTo(strDateB); }