Return-Path: Delivered-To: apmail-lucene-dev-archive@www.apache.org Received: (qmail 91220 invoked from network); 5 Feb 2011 03:27:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Feb 2011 03:27:59 -0000 Received: (qmail 78209 invoked by uid 500); 5 Feb 2011 03:27:58 -0000 Delivered-To: apmail-lucene-dev-archive@lucene.apache.org Received: (qmail 77224 invoked by uid 500); 5 Feb 2011 03:27:56 -0000 Mailing-List: contact dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list dev@lucene.apache.org Received: (qmail 76764 invoked by uid 99); 5 Feb 2011 03:27:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Feb 2011 03:27:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Feb 2011 03:27:50 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B554019053A for ; Sat, 5 Feb 2011 03:27:30 +0000 (UTC) Date: Sat, 5 Feb 2011 03:27:30 +0000 (UTC) From: "jawaid hakim (JIRA)" To: dev@lucene.apache.org Message-ID: <2111242802.1357.1296876450739.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Commented: (LUCENE-1070) DateTools with DAY resoltion dosn't work depending on your timezone MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LUCENE-1070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12990901#comment-12990901 ] jawaid hakim commented on LUCENE-1070: -------------------------------------- A few problems: 1) Looks like the round() method is doing the wrong thing for DAY resolution (wiping out DAY instead of HOUR) else if (resolution == Resolution.DAY) { calInstance.set(Calendar.HOUR_OF_DAY, 0); calInstance.set(Calendar.MINUTE, 0); calInstance.set(Calendar.SECOND, 0); calInstance.set(Calendar.MILLISECOND, 0); 2) If java.sql.Timestamp is passed in (e.g. by Hibernate Search) then all bets are of > DateTools with DAY resoltion dosn't work depending on your timezone > ------------------------------------------------------------------- > > Key: LUCENE-1070 > URL: https://issues.apache.org/jira/browse/LUCENE-1070 > Project: Lucene - Java > Issue Type: Bug > Components: Index > Affects Versions: 2.2 > Reporter: Mike Baroukh > > Hi. > There is another issue, closed, that introduced a bug : https://issues.apache.org/jira/browse/LUCENE-491 > Here is a simple TestCase : > DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm"); > Date d1 = df.parse("10/10/2008 10:00"); > System.err.println(DateTools.dateToString(d1, Resolution.DAY)); > Date d2 = df.parse("10/10/2008 00:00"); > System.err.println(DateTools.dateToString(d2, Resolution.DAY)); > this output : > 20081010 > 20081009 > So, days are the same, but with DAY resolution, the value indexed doesn't refer to the same day. > This is because of DateTools.round() : using a Calendar initialised to GMT can make that the Date given is on yesterday depending on my timezone . > The part I don't understand is why take a date for inputfield then convert it to calendar then convert it again before printing ? > This operation is supposed to "round" the date but using simply DateFormat to format the date and print only wanted fields do the same work, isn't it ? > The problem is : I see absolutly no solution actually. We could have a WorkAround if datetoString() took a Date as inputField but with a long, the timezone is lost. > I also suppose that the correction made on the other issue (https://issues.apache.org/jira/browse/LUCENE-491) is worse than the bug because it correct only for those who use date with a different timezone than the local timezone of the JVM. > So, my solution : add a DateTools.dateToString() that take a Date in parameter and deprecate the version that use a long. -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional commands, e-mail: dev-help@lucene.apache.org