ofbiz-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacques Le Roux <jacques.le.r...@les7arts.com>
Subject Re: Date Comparison Function
Date Fri, 06 Oct 2006 21:19:56 GMT
John,

As you may have seen David and Jacopo prefer to use already jakarta commons libraries.
That makes sense of course : less code to maintain, OFBiz is already pretty huge :o)

How might we organize that task ?

Jacques


> 
> My preference from a code management perspective would be to not have  
> any code in OFBiz that we could include a library for, especially the  
> jakarta commons libraries as sooner or later we'll probably have all  
> of them in OFBiz anyway... ;)
> 
> -David
> 
> 
> On Oct 6, 2006, at 7:24 PM, Jacques Le Roux wrote:
> 
> > Hi John, Jacopo and Chris,
> >
> > Perhaps before embedding the whole Apache's validator we may simply  
> > add the below method as suggested John ?
> >
> > If later we need more validations or other stuffes we migh include  
> > Apache's tools (validator, math, etc.)
> >
> > Jacques
> >
> > ----- Original Message -----
> > From: "John Martin" <pbwebguy@gmail.com>
> > To: <ofbiz-user@incubator.apache.org>
> > Sent: Friday, October 06, 2006 7:14 PM
> > Subject: Re: Date Comparison Function
> >
> >
> >> 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);
> >>     }
>

Mime
View raw message