lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@lucene.com>
Subject Re: Bug in current CVS source with DateField
Date Tue, 26 Nov 2002 16:24:54 GMT
[ I moved this discussion to lucene-dev.   -drc ]

This looks like a premature optimization gone bad.

Brian, you made this change.  Would you like to fix it, or should I?

Doug

Chris D wrote:
> 
> I found that the current code in CVS prevents a 
> org.apache.lucene.search.DateFilter from functioning properly.
> 
> This fragment is taken from org.apache.lucene.document.DateField
> 
> 
>    // Pad with leading zeros
>    if (s.length() < DATE_LEN) {
>      StringBuffer sb = new StringBuffer(s);
>      while (sb.length() < DATE_LEN)
>        sb.insert(0, ' ');
>      s = sb.toString();
>    }
> 
> 
> The code is padding ' ' (space) instead of zeros.
> 
> Line 5 should be:          sb.insert(0, '0');
> 
> Making this change and recompiling gave the expected results.
> 
> Looking back,  the lucene-1.2 source uses the following fragment:
> 
>    while (s.length() < DATE_LEN)
>      s = "0" + s;                  // pad with leading zeros
>


--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message