Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org Received: (qmail 56998 invoked from network); 12 Nov 2002 19:04:22 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Nov 2002 19:04:22 -0000 Received: (qmail 27016 invoked by uid 97); 12 Nov 2002 19:05:14 -0000 Delivered-To: qmlist-jakarta-archive-lucene-dev@jakarta.apache.org Received: (qmail 26946 invoked by uid 97); 12 Nov 2002 19:05:13 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 26895 invoked by uid 50); 12 Nov 2002 19:05:12 -0000 Date: 12 Nov 2002 19:05:12 -0000 Message-ID: <20021112190512.26894.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: lucene-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 14485] New: - Lucene 1.3dev1-2002-10-27 : NumberFormat Exception while parsing Date by DateField.stringToTime(String s) method X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14485 Lucene 1.3dev1-2002-10-27 : NumberFormat Exception while parsing Date by DateField.stringToTime(String s) method Summary: Lucene 1.3dev1-2002-10-27 : NumberFormat Exception while parsing Date by DateField.stringToTime(String s) method Product: Lucene Version: CVS Nightly - Specify date in submission Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Other AssignedTo: lucene-dev@jakarta.apache.org ReportedBy: max@osua.de This bug appears on my system with the lataest nightly build 2002-10-27. I've got NumberFormat Exception when trying to parse back string representetion of date to Java long type: java.lang.NumberFormatException: d8ae40fe at java.lang.Long.parseLong(Unknown Source) at org.apache.lucene.document.DateField.stringToTime(Unknown Source) I guess the reason is the following portion of code in the timeToString method of org.apache.lucene.document.DateField class (lines 111-112): ... while (sb.length() < DATE_LEN) sb.insert(0, ' '); // inserts leading spaces s = sb.toString(); } return s; } So, it appears, that the value, returned by the method, may contain leading spaces, and thus, back conversion by Long.parseLong method brings NimberFormatException. I changed the code of the stringToTime method to trim the string before the parsing and it fixes the problem: public static long stringToTime(String s) { return Long.parseLong(s.trim(), Character.MAX_RADIX); } -- To unsubscribe, e-mail: For additional commands, e-mail: