lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jawaid hakim (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-1070) DateTools with DAY resoltion dosn't work depending on your timezone
Date Sat, 05 Feb 2011 03:32:30 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-1070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12990903#comment-12990903
] 

jawaid hakim commented on LUCENE-1070:
--------------------------------------

Please disregard the first (1) point of my last comment. But the java.sql.Timestamp issue
is real.

> 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


Mime
View raw message