« Return to Thread: [jira] Created: (LUCENE-1653) Change DateTools to not create a Calendar in every call to dateToString or timeToString

[jira] Commented: (LUCENE-1653) Change DateTools to not create a Calendar in every call to dateToString or timeToString

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View in Thread


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

Mark Miller commented on LUCENE-1653:
-------------------------------------

Looks like a good change to me. Only downside I see is that round was not synced before, but now it is. Seems the benefits outweigh though - doesn't have to make the cal each time, and avoids double cal creation that happened when other methods called round. Anyone else have a comment before I commit?

> Change DateTools to not create a Calendar in every call to dateToString or timeToString
> ---------------------------------------------------------------------------------------
>
>                 Key: LUCENE-1653
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1653
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Other
>            Reporter: Shai Erera
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1653.patch
>
>
> DateTools creates a Calendar instance on every call to dateToString and timeToString. Specifically:
> # timeToString calls Calendar.getInstance on every call.
> # dateToString calls timeToString(date.getTime()), which then instantiates a new Date(). I think we should change the order of the calls, or not have each call the other.
> # round(), which is called from timeToString (after creating a Calendar instance) creates another (!) Calendar instance ...
> Seems that if we synchronize the methods and create the Calendar instance once (static), it should solve it.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@...
For additional commands, e-mail: java-dev-help@...

 « Return to Thread: [jira] Created: (LUCENE-1653) Change DateTools to not create a Calendar in every call to dateToString or timeToString