Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 19418 invoked from network); 24 Aug 2006 07:21:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Aug 2006 07:21:49 -0000 Received: (qmail 88692 invoked by uid 500); 24 Aug 2006 07:21:42 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 88657 invoked by uid 500); 24 Aug 2006 07:21:42 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 88645 invoked by uid 99); 24 Aug 2006 07:21:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2006 00:21:41 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [169.229.70.167] (HELO rescomp.berkeley.edu) (169.229.70.167) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2006 00:21:41 -0700 Received: by rescomp.berkeley.edu (Postfix, from userid 1007) id CA5BD5B794; Thu, 24 Aug 2006 00:21:18 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by rescomp.berkeley.edu (Postfix) with ESMTP id C46497F403 for ; Thu, 24 Aug 2006 00:21:18 -0700 (PDT) Date: Thu, 24 Aug 2006 00:21:18 -0700 (PDT) From: Chris Hostetter To: java-user@lucene.apache.org Subject: Re: DateTools.set- In-Reply-To: <200608240013781.SM02072@TS18> Message-ID: References: <200608240013781.SM02072@TS18> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I think the confusion here is that when DateTools looks at a Date object and a Resolution, it does it's calculations in GMT (so when you ask what "day" it is at a particular moment, it tells you the current day in GMT, when you ask which month, it tells you the month in GMT, etc...) This may seem arbitrary, and it is, but it's fixed like that so that no matter what Locale your jvm is configured with, you'll get the same results from an index as everybody else. If you print the Date object with a robust DateFormatter (instead of the default toString()) you'll see what i mean. : Date: Thu, 24 Aug 2006 00:11:17 -0500 : From: Paul Snyder : Reply-To: java-user@lucene.apache.org : To: java-user@lucene.apache.org : Subject: DateTools.set- : : I have a question about DateTools conversions. I am having trouble with : results of trying to store a date truncated to DAY resolution. : : Here is an example. : : ---------------------------------------------------------------------------- : ---- : : OK: : : DateTools.stringToDate(DateTools.dateToString(new Date("01/12/2006"), : DateTools.Resolution.SECOND)) : (java.util.Date) Thu Jan 12 00:00:00 CST 2006 : : NOT OK: : : DateTools.stringToDate(DateTools.dateToString(new Date("01/12/2006"), : DateTools.Resolution.DAY)) : (java.util.Date) Wed Jan 11 18:00:00 CST 2006 : : ---------------------------------------------------------------------------- : ---- : : The problem appears to be on the stringToDate conversion. : : ---------------------------------------------------------------------------- : ---- : : OK: : : DateTools.dateToString(new Date("01/12/2006"), DateTools.Resolution.DAY) : (java.lang.String) 20060112 : : NOT OK: : : DateTools.stringToDate("20060112") : (java.util.Date) Wed Jan 11 18:00:00 CST 2006 : : ---------------------------------------------------------------------------- : ---- : : I assume there is something simple I am missing, please, anybody, WHAT? : : Local time zone is GMT-0600 (CST) : : OS is Redhat E-L 4. : : jre is from Sun jdk 1.4 : : Lucene is lucene-core-2.0.1.jar : : Paul Snyder : Web Programmer : Post-Bulletin Company, L.L.C. : Phone (507) 281-7402 Fax (507) 281-7491 TollFree (800) 562-1758 : http://www.postbulletin.com http://www.pbinternetservices.com : http://www.rochestermn.com : : : : --------------------------------------------------------------------- : To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org : For additional commands, e-mail: java-user-help@lucene.apache.org : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org